Another Revolution Success Story

Brian Yennie briany at qldlearning.com
Mon Jun 28 23:01:58 EDT 2004


> yes, string handling is pretty good - but I'm surprised that Rev has 
> no built-in support for CSV files. They are a pretty common 
> interchange format, but handling the variations commonly found makes 
> it non-trivial to do this properly - quoted fields, delimiter in 
> quoted fields, escaped or doubled quotes within a field, etc.
>
> Has anyone written and contributed a library to avoid others having to 
> "roll-your-own" ?

FWIW, almost all tools that produce CSV files can also do tab 
delimited, which is much easier to deal with.
Heck, why anyone does anything other than picking a row and column 
delimiter and replacing them with escape codes if necessary in the 
actual data is beyond me.

Perhaps there's a good CSV-to-tab-delimited converter out there =).

Given tab-delimited data it's real easy to do lots of things:

set the itemDelimiter to tab

repeat for each line l in someData
    put item 1 of l into field1
    put item 2 of l into field2
    replace "\r" with return into field2
    replace "\t" with tab in field2
    ...
end repeat

...

put line 42 of someData into record42

...

sort lines of someData by item 3 of each

...

split someData using return and tab
put someData[115] into recordID115

etc...

- Brian



More information about the use-livecode mailing list