Comma-delimited values
Mark Schonewille
m.schonewille at economy-x-talk.com
Mon Mar 8 13:01:51 EST 2010
Hi Gregory,
Does this work for you?
function csv2tab theData
repeat for each line myLine in theData
repeat for each word myWord in myLine
if char 1 of myWord is quote and (char -2 of myWord is
quote or char -1 of myWord is quote) then
replace comma with "<\#>" in myWord
end if
put myWord after myNewData
end repeat
put cr after myNewData
end repeat
replace comma with tab in myNewData
replace "<\#>" with comma in myNewData
return myNewData
end csv2tab
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Economy-x-Talk is always looking for new software development
projects. Feel free to contact me for a quote.
Op 8 mrt 2010, om 18:44 heeft Gregory Lypny het volgende geschreven:
> Hello everyone,
>
> I'm creating an app that imports comma-delimited tables. A few
> lines might look like this, where there are 14 items per line.
>
> "Mon, Jan 18 , 2010",9:14 AM,130557,4319,Trade,Buy,X,
> 135,8.25,10,-82.5,1417.5,20,10
> "Mon, Jan 18 , 2010",9:14 AM,130558,4371,Accept,Your ASK,X,
> 135,8.25,10,82.5,1582.5,0,10
>
> My problem is that Rev treats each date in quotes as three items
> rather than one. I convert the comma delimiters to tab by setting
> the itemDelimiter to comma and then running the lines through nested
> repeat-for-each loops as
>
> repeat for each line thisLine in dataTable
> repeat for each item thisItem in thisLine
> put thisItem & tab after newLine
> end repeat
> -- more stuff here
> end repeat
>
> I end up with
>
> "Mon (as the first item)
> Jan 18 (as the second)
> 2010" (as the third)
>
> Any suggestions as how I might get the date treated as one item?
>
> Regards,
>
> Gregory
More information about the use-livecode
mailing list