<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Manipulate .csv through MaxScript? in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263936#M17925</link>
    <description>I know clear as mud &lt;BR /&gt;and how do I check for a number if we converted the csv string into an array of strings ?&lt;BR /&gt;maxscript variables don't care what type they are but they can be smart(ish).&lt;BR /&gt;&lt;BR /&gt;Try these in the listener&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;myVar = "iamnotanumber" as integer&lt;/PRE&gt;&lt;BR /&gt;string to int = undefined&lt;BR /&gt;&lt;PRE&gt;myVar = "one" as integer&lt;/PRE&gt;&lt;BR /&gt;string as int = undefined&lt;BR /&gt;&lt;PRE&gt;myVar = "1" as integer&lt;/PRE&gt;&lt;BR /&gt;string as int =  1 = smart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;we can use this to fix the getMyVars function&lt;BR /&gt;&lt;BR /&gt;Currently we have:&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;--Vars Collection Function&lt;BR /&gt;fn getMyVars delimitedArray addToInt =&lt;BR /&gt;(&lt;BR /&gt; --this var is before the text field so nothing is added&lt;BR /&gt;    myVar1 = delimitedArray &lt;BR /&gt; --the rest of the vars are after the text field &lt;BR /&gt; myVar2 = delimitedArray&lt;BR /&gt; myVar3 = delimitedArray&lt;BR /&gt; myVar4 = delimitedArray&lt;BR /&gt; &lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;this line we need to collect anyway.(the data wanted always starts here)&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;myVar1 = delimitedArray&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;and we need to check delimitedArray once to see if its a number(data finished ??)&lt;BR /&gt;if its not a number look in the next element and so on until we hit a number.&lt;BR /&gt;&lt;BR /&gt;a do while loop seems like a good candidate because it will check at least once&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;gotit = false --a bool set to false until we find a number&lt;BR /&gt;indexVar = 3 --a temp var used to keep track of where in the array we are.&lt;BR /&gt;do(&lt;BR /&gt;tmpVar = delimitedArray as integer --check element for a number&lt;BR /&gt; if tmpVar != undefined then&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is not undefined so we got a number :) &lt;BR /&gt; gotit = true&lt;BR /&gt; )&lt;BR /&gt; else&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is undefined we got a string&lt;BR /&gt; --move to next element&lt;BR /&gt; indexVar = indexVar + 1&lt;BR /&gt; )&lt;BR /&gt;)while gotit != true --loop&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;Now we have the end of the data we want &lt;BR /&gt;Lets check to see where it is.&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;if indexVar &amp;gt; 3 then --did we loop or was all the data in &lt;BR /&gt;(&lt;BR /&gt; --we did loop so fix string here&lt;BR /&gt; &lt;BR /&gt; --the last element we looked at was a number so &lt;BR /&gt; --we need to backup one&lt;BR /&gt; indexVar = indexVar - 1&lt;BR /&gt; for i = 3 to indexVar do&lt;BR /&gt; (&lt;BR /&gt; myVar1 = myVar1 + delimitedArray&lt;I&gt;&lt;BR /&gt; i = i + 1&lt;BR /&gt; )&lt;BR /&gt;)&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;ok hopefully that should have sorted it, update the example script test strings&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;loaded_str1 = "#,Total_Planning,1,,text field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;--extra commas in  and in text field csv string(+2)&lt;BR /&gt;loaded_Str2 = "#,Total_Pla,nn,ing,55,,text,,field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;and update the getMyVar function&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;--Vars Collection Function&lt;BR /&gt;fn getMyVars delimitedArray addToInt =&lt;BR /&gt;(&lt;BR /&gt; --this var is before the text field so nothing is added&lt;BR /&gt;    myVar1 = delimitedArray &lt;BR /&gt;&lt;BR /&gt; gotit = false --a bool set to false til we find a number&lt;BR /&gt; indexVar = 3 --a temp var used to keep track of where in the array we are.&lt;BR /&gt; do(&lt;BR /&gt; tmpVar = delimitedArray as integer --check element for a number&lt;BR /&gt; if tmpVar != undefined then&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is not undefined so we got a number :) &lt;BR /&gt; gotit = true&lt;BR /&gt; )&lt;BR /&gt; else&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is undefined we got a string&lt;BR /&gt; --move to next element&lt;BR /&gt; indexVar = indexVar + 1&lt;BR /&gt; )&lt;BR /&gt; )while gotit != true --loop while not true&lt;BR /&gt;&lt;BR /&gt; if indexVar &amp;gt; 3 then --did we loop or was all the data in &lt;BR /&gt; (&lt;BR /&gt; --we did loop so fix string here&lt;BR /&gt; &lt;BR /&gt; --the last element we looked at was a number so &lt;BR /&gt; --we need to backup one&lt;BR /&gt; indexVar = indexVar - 1&lt;BR /&gt; for i = 3 to indexVar do&lt;BR /&gt; (&lt;BR /&gt; myVar1 = myVar1 + delimitedArray&lt;I&gt;&lt;BR /&gt; i = i + 1&lt;BR /&gt; )&lt;BR /&gt; )&lt;BR /&gt; --the rest of the vars are after the text field &lt;BR /&gt; myVar2 = delimitedArray&lt;BR /&gt; myVar3 = delimitedArray&lt;BR /&gt; myVar4 = delimitedArray &lt;BR /&gt;)--end of getMyVars&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;The output should be the same as before.&lt;BR /&gt;Let me know how you get on &lt;BR /&gt;billP</description>
    <pubDate>Fri, 05 Oct 2012 12:45:13 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-10-05T12:45:13Z</dc:date>
    <item>
      <title>Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263924#M17913</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;i'm trying to make a (my first) maxscript wich allows me to import a .csv file as an animated timeline with some interaction from the user.&lt;BR /&gt;My .csv is built up per line as follows:&lt;BR /&gt;&lt;FONT color="orange"&gt;,,,,,,,,,&lt;/FONT&gt;&lt;BR /&gt;In this line the  and all the following values are irrelevant to me. I've attached an example of the .csv file.&lt;BR /&gt;&lt;BR /&gt;What I want to accomplish is that the MaxScript evaluates the second line in the .csv file&amp;amp;#40;the first contains headers&amp;amp;#41; and calculates the total duration of the Task.&lt;BR /&gt;I.e: #,Total_Planning,#,#,#,#,#,27-9-2012 5:00,2-10-2012 2:00,Construct&lt;BR /&gt;- So the total construction time would be 117 hours. This is easy for us to calculate, but is there a way to let MaxScript do this? Taking into account that the months do not always contain the same amount of days.&lt;BR /&gt;What I'm trying to avoid is to manipulate the .csv file myself.&lt;BR /&gt;I know excel can calculate the difference but can MaxScript start/call this function? (As I'm trying to avoid altering the .csv file myself)&lt;BR /&gt;&lt;BR /&gt;This calculation is needed multiple times where the resulting values will be used as variables for different things, therefor I want to use MacScript. So far I haven't come further then defining the variables based on a filterstring. &lt;BR /&gt;I'm also curious about a way of coping with empty values in the .csv file. &lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;PS. I know the numbers for the string filter don't correspond to the layout of the .csv I mentioned above. I'm using the script from below on a test .csv that I wrote myself for now. Using the print part of the code to check the values of the variables.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;(&lt;BR /&gt;fName = getOpenFileName caption:"Open file" types:"(*.csv)|*.csv|"&lt;BR /&gt;fS = undefined&lt;BR /&gt;if fName != undefined then&lt;BR /&gt;   fS = openfile fName&lt;BR /&gt;if fS != undefined do&lt;BR /&gt;   (&lt;BR /&gt;      while (not eof(fS)) do&lt;BR /&gt;         (&lt;BR /&gt;         PR = readline fS; &lt;BR /&gt;  PRF = filterstring PR "," &lt;BR /&gt;  TN=PRF &lt;BR /&gt;  TS=PRF &lt;BR /&gt;  TE=PRF &lt;BR /&gt;  TT=PRF&lt;BR /&gt;  &lt;BR /&gt; TSF = filterstring TS "- :" &lt;BR /&gt; DS=TSF as integer&lt;BR /&gt; MS=TSF as integer&lt;BR /&gt; YS=TSF as integer&lt;BR /&gt; HS=TSF&lt;BR /&gt; MiS=TSF&lt;BR /&gt;  &lt;BR /&gt; TEF = filterstring TE "- :" &lt;BR /&gt; DE=TEF as integer&lt;BR /&gt; ME=TEF as integer&lt;BR /&gt; YE=TEF as integer&lt;BR /&gt; HE=TEF &lt;BR /&gt; MiE=TEF &lt;BR /&gt;  Print TN&lt;BR /&gt;  Print TS&lt;BR /&gt; Print DS&lt;BR /&gt; Print MS&lt;BR /&gt; Print YS&lt;BR /&gt; Print HS&lt;BR /&gt; Print MiS&lt;BR /&gt;  Print TE&lt;BR /&gt; Print DE&lt;BR /&gt; Print ME&lt;BR /&gt; Print YE&lt;BR /&gt; Print HE&lt;BR /&gt; Print MiE&lt;BR /&gt;  Print TT&lt;BR /&gt;  &lt;BR /&gt;         )--while&lt;BR /&gt; close fS&lt;BR /&gt; ) --fS&lt;BR /&gt;)&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2012 15:07:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263924#M17913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-17T15:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263925#M17914</link>
      <description>Ok, I've managed to manipulate my .csv file through making an OLE object link and pasting some filtered values to the OLE object.&lt;BR /&gt;One problem that is residing right now is that the .csv file is comma seperated but that there are text values in between the comma's that also contain a comma.&lt;BR /&gt;&lt;BR /&gt;I.e: 1,&lt;FONT color="red"&gt;"text, text)"&lt;/FONT&gt;,,,,,1,27-10-2012 15:55:00,27-10-2012 20:55:00,,,...&lt;BR /&gt;&lt;BR /&gt;Currently im using the filterstring command to seperate the values by comma:&lt;BR /&gt;&lt;PRE&gt;PR = readline fS;&lt;BR /&gt;PRF = filterstring PR "," Splitemptytokens:True&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The problem with this filterstring is that it will search for ANY comma in the line, and thus also contains the comma inside the text block delimited by the double quotes. Obviously I don't want this to happen, does anyone have a suggestion on how to tackle this?</description>
      <pubDate>Mon, 01 Oct 2012 11:02:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263925#M17914</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-01T11:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263926#M17915</link>
      <description>does the csv string have a known amount of commas ??</description>
      <pubDate>Mon, 01 Oct 2012 13:08:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263926#M17915</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-01T13:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263927#M17916</link>
      <description>Yes, a normal csv string contains 28 commas, unless there's a comma inside a text block. Then it cannot be certain how many comma's the string contains.</description>
      <pubDate>Mon, 01 Oct 2012 13:11:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263927#M17916</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-01T13:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263928#M17917</link>
      <description>Ok if a normal string contains 28 commas you can use array .count to work out if you have extra commas in the text field.&lt;BR /&gt;&lt;BR /&gt;the maxscript help file gives an example of a function that returns an array with all entries in your string.&lt;BR /&gt;&lt;PRE&gt;Frequently Asked Questions-&amp;gt;Practical Questions-&amp;gt;Working With Maxscript Values-&amp;gt;&lt;BR /&gt;How do I filter a string including empty entries&lt;/PRE&gt;&lt;BR /&gt;You can now check the array count if its 28 no extra commas so you know where the vars &lt;BR /&gt;are that you want just pass the array to a function to collect them.&lt;BR /&gt;&lt;BR /&gt;If there are more then 28 in the array count you know that the text field has commas inside&lt;BR /&gt;so pass array and how many extra commas you have to a function that uses the array &lt;BR /&gt;index+extra_comma_count to workout where in the string the vars are that you want.&lt;BR /&gt;(remember you will not need the extra comma count if you collect any vars before the text field)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope that makes some sense &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 01 Oct 2012 13:59:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263928#M17917</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-01T13:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263929#M17918</link>
      <description>Wow just reread this way too much coffee and not enough commas &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;</description>
      <pubDate>Tue, 02 Oct 2012 09:47:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263929#M17918</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T09:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263930#M17919</link>
      <description>Hopefully this will make things easier to understand.&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;/*&lt;BR /&gt;Example: &lt;BR /&gt;collection of var from csv string with possible &lt;BR /&gt;extra commas in a known text field.&lt;BR /&gt;No error checking included&lt;BR /&gt;*/&lt;BR /&gt;-----------------------------------------------------------------&lt;BR /&gt;--normal csv string (9 commas)&lt;BR /&gt;loaded_str1 = "#,Total_Planning,,,text field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;--extra commas in text field csv string(+2)&lt;BR /&gt;loaded_Str2 = "#,Total_Planning,,,text,,field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;--Array to hold the delimited strings&lt;BR /&gt;myArray = #()&lt;BR /&gt;--Vars to hold collected items&lt;BR /&gt;myVar1&lt;BR /&gt;myVar2&lt;BR /&gt;myVar3&lt;BR /&gt;myVar4&lt;BR /&gt;&lt;BR /&gt;--Reusable Function From The Maxscript Help Docs &lt;BR /&gt;--Pass string to work on and a string or array of delimiters &lt;BR /&gt;fn filterString2 theString theDelimiters =&lt;BR /&gt;(&lt;BR /&gt; theTokens = #() --array of tokens to return&lt;BR /&gt; ready = false&lt;BR /&gt; while not ready do --repeat until no more delimiters can be found&lt;BR /&gt; (&lt;BR /&gt;  ready = true --raise a flag that we are done&lt;BR /&gt;  thePosArray = #() --init. an array to hold possible split positions&lt;BR /&gt;  for i = 1 to theDelimiters.count do --go through all delimiters&lt;BR /&gt;  (&lt;BR /&gt;   checkPos = findString theString theDelimiters&lt;I&gt; --check if the delimiter is in the string&lt;BR /&gt;   if checkPos != undefined do append thePosArray checkPos --if it is, add to the split positions array&lt;BR /&gt;  ) --end i loop &lt;BR /&gt;  if thePosArray.count &amp;gt; 0 then --if the array has any splitpositions,&lt;BR /&gt;  (&lt;BR /&gt;   sort thePosArray --sort the array in ascending order&lt;BR /&gt;   checkPos = thePosArray --grab the first position&lt;BR /&gt;   aToken = substring theString 1 (checkPos-1) --take the token from start to the split pos. - 1&lt;BR /&gt;   append theTokens aToken --add the token to the array of tokens&lt;BR /&gt;   theString = substring theString (checkPos+1) theString.count --remove the token and the delimiter from the string&lt;BR /&gt;   ready = false --lower the flag because we are not ready yet&lt;BR /&gt;  ) --end if&lt;BR /&gt; ) --end while loop&lt;BR /&gt; append theTokens theString --add what is left of the string to the array&lt;BR /&gt; theTokens --return the array of tokens&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;--Vars Collection Function&lt;BR /&gt;fn getMyVars delimitedArray addToInt =&lt;BR /&gt;(&lt;BR /&gt; --this var is before the text field so nothing is added&lt;BR /&gt;    myVar1 = delimitedArray &lt;BR /&gt; --the rest of the vars are after the text field &lt;BR /&gt; myVar2 = delimitedArray&lt;BR /&gt; myVar3 = delimitedArray&lt;BR /&gt; myVar4 = delimitedArray&lt;BR /&gt; &lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--pass the normal csv string and delimiter and fill myArray&lt;BR /&gt;--for testing edit loaded_Str1 to loaded_Str2 here &lt;BR /&gt;myArray = filterString2 loaded_Str1 ","&lt;BR /&gt;&lt;BR /&gt;--we know in this example the normal csv has 9 commas but myArray will have 10 elements&lt;BR /&gt;--so lets check the element count &lt;BR /&gt;if myArray.count == 10 then&lt;BR /&gt;(&lt;BR /&gt; --pass myArray and zero (no extra commas)&lt;BR /&gt; getMyVars myArray 0&lt;BR /&gt;)&lt;BR /&gt;else &lt;BR /&gt;(&lt;BR /&gt; --loaded_Str2 has more than 10 elements so will land here.&lt;BR /&gt; --workout how many extras commas are in the text field &lt;BR /&gt; myInt = myArray.count - 10&lt;BR /&gt; --pass myArray and myInt (extra commas)&lt;BR /&gt; getMyVars myArray myInt&lt;BR /&gt;)&lt;BR /&gt; --debug&lt;BR /&gt; --print myVar1&lt;BR /&gt; --print myVar2&lt;BR /&gt; --print myVar3&lt;BR /&gt; --print myVar4&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;loaded_Str1 should return &lt;BR /&gt;"Total_Planning" &lt;BR /&gt;"27-9-2012 5:00" &lt;BR /&gt;"2-10-2012 2:00" &lt;BR /&gt;"Construct"&lt;BR /&gt;loaded_Str2 with extra commas should return &lt;BR /&gt;"Total_Planning" &lt;BR /&gt;"27-9-2012 5:00" &lt;BR /&gt;"2-10-2012 2:00" &lt;BR /&gt;"Construct"&lt;BR /&gt;&lt;BR /&gt;Hope that helps &lt;BR /&gt;billP</description>
      <pubDate>Tue, 02 Oct 2012 10:16:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263930#M17919</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263931#M17920</link>
      <description>Thanks Bill for the help, and thank you so much for the elaboration. As you allready guessed i didn't understand anything of what you said before.&lt;BR /&gt;I'm still trying to figure out what does exactly what, but the basics are great! It will take me some time to rebuild it to my needs, but who cares about that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Tue, 02 Oct 2012 12:09:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263931#M17920</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T12:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263932#M17921</link>
      <description>Bill thanks again!&lt;BR /&gt;I've got a question though: If there would be a comma inside the Total_planning field, and I would want the MyVar1 to be: MyVar1 = Total Planning, how would i achieve that?&lt;BR /&gt;&lt;PRE&gt;loaded_Str2 = "#,Total,Planning,,,text,,field,,,27-9-2012 5:00,2-10-2012 2:00,Construct"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;A simple:&lt;BR /&gt;&lt;PRE&gt;myVar1 = delimitedArray + delimitedArray &lt;/PRE&gt;&lt;BR /&gt;Would achieve this, but it would also show me the 3rd array value for all other strings. Which i dont want. &lt;BR /&gt;&lt;BR /&gt;I want it to read the "Total, Planning" text field as 1 field. (Given the fact that it is possible to have multiple text fields, all with possibly multiple comma's)</description>
      <pubDate>Tue, 02 Oct 2012 12:46:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263932#M17921</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T12:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263933#M17922</link>
      <description>Do you know what comes after the Total planning ?&lt;BR /&gt;ie:&lt;BR /&gt;"#,Total,Planning,???,,text,,field,,,27-9-2012 5:00,2-10-2012 2:00,Construct"&lt;BR /&gt;a number or a string ?? and is it always the same type?</description>
      <pubDate>Tue, 02 Oct 2012 13:16:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263933#M17922</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T13:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263934#M17923</link>
      <description>Yes I do know, it is always a number.&lt;BR /&gt;A normal line in the .csv looks like this: (S = string, D=Date)&lt;BR /&gt;#,S,#,#,D,D,#,D,D,S,S,S,S,#,#,S,S,#,#,S,S,S,S,S,S,S,S,S,S&lt;BR /&gt;Out of which im only interested in entities: 2 (S), 8 (D), 9 (D), 10 (S), 20 (S)&lt;BR /&gt;And where only entity 2 (the string) can contain extra comma's.</description>
      <pubDate>Thu, 04 Oct 2012 07:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263934#M17923</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-04T07:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263935#M17924</link>
      <description>good &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;If you know a number follows the string you want &lt;BR /&gt;you can test for it.&lt;BR /&gt;&lt;BR /&gt;Short example&lt;BR /&gt;S1 = #,Total Planning,1&lt;BR /&gt;S2 = #,Total,Planning,9&lt;BR /&gt;S3 = #,Total,Plan,ning,3&lt;BR /&gt;&lt;BR /&gt;you want 2 but 3 and 4 or more may also have parts of your data.&lt;BR /&gt;But a nice number follows the data you want.&lt;BR /&gt;&lt;BR /&gt;This gives you some logic to work with:&lt;BR /&gt;collect array element 2 always collected&lt;BR /&gt;check array am i a number ??&lt;BR /&gt;no-&amp;gt;check next element in the array for number.&lt;BR /&gt;yes-&amp;gt;the end of the data wanted was in the last element &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Starting at 2 and looping forward for the short examples&lt;BR /&gt;S1 -&amp;gt;Yes (all of the string is in )&lt;BR /&gt;S2 -&amp;gt;No-&amp;gt;Yes (need and  to get all of the string)&lt;BR /&gt;S3 -&amp;gt;No-&amp;gt;No-&amp;gt;Yes (need to  to get all of the string)&lt;BR /&gt;&lt;BR /&gt;A good rule of thumb:&lt;BR /&gt;All the data in the file/string can be helpful even if you&lt;BR /&gt;don't want or need it.&lt;BR /&gt;&lt;BR /&gt;billP</description>
      <pubDate>Thu, 04 Oct 2012 16:27:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263935#M17924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-04T16:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263936#M17925</link>
      <description>I know clear as mud &lt;BR /&gt;and how do I check for a number if we converted the csv string into an array of strings ?&lt;BR /&gt;maxscript variables don't care what type they are but they can be smart(ish).&lt;BR /&gt;&lt;BR /&gt;Try these in the listener&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;myVar = "iamnotanumber" as integer&lt;/PRE&gt;&lt;BR /&gt;string to int = undefined&lt;BR /&gt;&lt;PRE&gt;myVar = "one" as integer&lt;/PRE&gt;&lt;BR /&gt;string as int = undefined&lt;BR /&gt;&lt;PRE&gt;myVar = "1" as integer&lt;/PRE&gt;&lt;BR /&gt;string as int =  1 = smart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;we can use this to fix the getMyVars function&lt;BR /&gt;&lt;BR /&gt;Currently we have:&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;--Vars Collection Function&lt;BR /&gt;fn getMyVars delimitedArray addToInt =&lt;BR /&gt;(&lt;BR /&gt; --this var is before the text field so nothing is added&lt;BR /&gt;    myVar1 = delimitedArray &lt;BR /&gt; --the rest of the vars are after the text field &lt;BR /&gt; myVar2 = delimitedArray&lt;BR /&gt; myVar3 = delimitedArray&lt;BR /&gt; myVar4 = delimitedArray&lt;BR /&gt; &lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;this line we need to collect anyway.(the data wanted always starts here)&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;myVar1 = delimitedArray&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;and we need to check delimitedArray once to see if its a number(data finished ??)&lt;BR /&gt;if its not a number look in the next element and so on until we hit a number.&lt;BR /&gt;&lt;BR /&gt;a do while loop seems like a good candidate because it will check at least once&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;gotit = false --a bool set to false until we find a number&lt;BR /&gt;indexVar = 3 --a temp var used to keep track of where in the array we are.&lt;BR /&gt;do(&lt;BR /&gt;tmpVar = delimitedArray as integer --check element for a number&lt;BR /&gt; if tmpVar != undefined then&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is not undefined so we got a number :) &lt;BR /&gt; gotit = true&lt;BR /&gt; )&lt;BR /&gt; else&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is undefined we got a string&lt;BR /&gt; --move to next element&lt;BR /&gt; indexVar = indexVar + 1&lt;BR /&gt; )&lt;BR /&gt;)while gotit != true --loop&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;Now we have the end of the data we want &lt;BR /&gt;Lets check to see where it is.&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;if indexVar &amp;gt; 3 then --did we loop or was all the data in &lt;BR /&gt;(&lt;BR /&gt; --we did loop so fix string here&lt;BR /&gt; &lt;BR /&gt; --the last element we looked at was a number so &lt;BR /&gt; --we need to backup one&lt;BR /&gt; indexVar = indexVar - 1&lt;BR /&gt; for i = 3 to indexVar do&lt;BR /&gt; (&lt;BR /&gt; myVar1 = myVar1 + delimitedArray&lt;I&gt;&lt;BR /&gt; i = i + 1&lt;BR /&gt; )&lt;BR /&gt;)&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;ok hopefully that should have sorted it, update the example script test strings&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;loaded_str1 = "#,Total_Planning,1,,text field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;--extra commas in  and in text field csv string(+2)&lt;BR /&gt;loaded_Str2 = "#,Total_Pla,nn,ing,55,,text,,field,,,27-9-2012 5:00,2-10-2012 2:00,Construct" &lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;and update the getMyVar function&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;--Vars Collection Function&lt;BR /&gt;fn getMyVars delimitedArray addToInt =&lt;BR /&gt;(&lt;BR /&gt; --this var is before the text field so nothing is added&lt;BR /&gt;    myVar1 = delimitedArray &lt;BR /&gt;&lt;BR /&gt; gotit = false --a bool set to false til we find a number&lt;BR /&gt; indexVar = 3 --a temp var used to keep track of where in the array we are.&lt;BR /&gt; do(&lt;BR /&gt; tmpVar = delimitedArray as integer --check element for a number&lt;BR /&gt; if tmpVar != undefined then&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is not undefined so we got a number :) &lt;BR /&gt; gotit = true&lt;BR /&gt; )&lt;BR /&gt; else&lt;BR /&gt; (&lt;BR /&gt; --tmpVar is undefined we got a string&lt;BR /&gt; --move to next element&lt;BR /&gt; indexVar = indexVar + 1&lt;BR /&gt; )&lt;BR /&gt; )while gotit != true --loop while not true&lt;BR /&gt;&lt;BR /&gt; if indexVar &amp;gt; 3 then --did we loop or was all the data in &lt;BR /&gt; (&lt;BR /&gt; --we did loop so fix string here&lt;BR /&gt; &lt;BR /&gt; --the last element we looked at was a number so &lt;BR /&gt; --we need to backup one&lt;BR /&gt; indexVar = indexVar - 1&lt;BR /&gt; for i = 3 to indexVar do&lt;BR /&gt; (&lt;BR /&gt; myVar1 = myVar1 + delimitedArray&lt;I&gt;&lt;BR /&gt; i = i + 1&lt;BR /&gt; )&lt;BR /&gt; )&lt;BR /&gt; --the rest of the vars are after the text field &lt;BR /&gt; myVar2 = delimitedArray&lt;BR /&gt; myVar3 = delimitedArray&lt;BR /&gt; myVar4 = delimitedArray &lt;BR /&gt;)--end of getMyVars&lt;BR /&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;The output should be the same as before.&lt;BR /&gt;Let me know how you get on &lt;BR /&gt;billP</description>
      <pubDate>Fri, 05 Oct 2012 12:45:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263936#M17925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-05T12:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263937#M17926</link>
      <description>LOL, Thanks Bill! I´ll try this as soon as i´m done touching up the part of the script i´m working on right now. All this scripting looks so easy once you´ve found the logic, but i know it is not.&lt;BR /&gt;Therefore: THANKS!</description>
      <pubDate>Fri, 05 Oct 2012 12:51:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263937#M17926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-05T12:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulate .csv through MaxScript?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263938#M17927</link>
      <description>Hey Bill,&lt;BR /&gt;&lt;BR /&gt;i'm testing the script right now and it works fine!&lt;BR /&gt;I made some very minor tweaks to it:&lt;BR /&gt;I removed the Filterstring2 function and am now using:&lt;BR /&gt;&lt;PRE&gt;myArray = filterString loaded_Str1 "," splitemptytokens: True&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I inserted an if fuction in the MyVars function right beneath   myVar1 = delimitedArray:&lt;BR /&gt;&lt;PRE&gt; myVar1 = delimitedArray &lt;BR /&gt;if addToInt != 0 then...&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;as it is useless to run the addtoint function if it is 0, because then&lt;BR /&gt;&lt;PRE&gt;myVar1 = delimitedArray&lt;/PRE&gt; is always true.&lt;BR /&gt;Besides it gave me an error on the first line of the .csv file where i dont have any numbers, which i corrected in this way.</description>
      <pubDate>Mon, 08 Oct 2012 10:58:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/manipulate-csv-through-maxscript/m-p/4263938#M17927</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-08T10:58:31Z</dc:date>
    </item>
  </channel>
</rss>

