How to extract specific columns/line items from a CSV file?

Mike Bonner bonnmike at gmail.com
Tue Sep 20 16:32:30 EDT 2016


If a file you can do this..

repeat for each line tline in url "file:yourfilename.csv"
 put item 1 of tLine & comma & item 3 of tline & comma & item 15 of tLine &
return after tExtracted
end repeat
delete the last char of tExtracted -- remove the extraneous return

Or you can put them into an array or whatever. It should be VERY fast.  If
the files are very large, you can instead open the file for read, read a
line, extract the data as above, and repeat till the end of the file. I
think using repeat for each with a file url loads the whole thing at once
then goes line to line, but I'm not sure of that.

On Tue, Sep 20, 2016 at 2:16 PM, Keith Clarke <keith.clarke at me.com> wrote:

> Hi folks,
> I’ve a large number of sizeable CSV files from each of which I need to
> extract just 2 or 3 specific columns. Creating nested iterations through
> every item in every line seems somewhat inefficient - as does loading each
> full file into memory - so I feel I must be missing a trick here.
>
> Does Livecode support any elegant way of directly manipulating or
> ‘querying’ (like SQL) delimited data, to extract numbered (or named)
> columns/items - such as 1(Id), 3(Name) & 15(Summary) - from in each line
> from a CSV container or direct from a file/URL?
> Best,
> Keith..
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list