Re: How to parse CSV
Re: How to parse CSV
- Subject: Re: How to parse CSV
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 23 Jan 2008 08:56:16 -0500
What are you doing with the javascript string? If it's going into a
Safari "do javascript" command, then yeah, you need the whole string
at once, but if you're writing it to a file you can deal with it
piecemeal...
You could use Perl via "do shell script", but you'd have to either
install the Text::CSV module from CPAN, or roll your own. Better, I
think, to use Python or Ruby, which come with CSV parsers
preinstalled. I believe they also both come with the ability to
output lists in Javascript syntax (technically YAML, but with the
option to use the JSON-compatible subset of YAML).
On 1/23/08, Benedikt Quirmbach <email@hidden> wrote:
> Yes, I'm thinking about reading the file line by line.
>
> But at the end I need the converted csv data as a string. The goal of
> this project is to build a string with the csv data as a JavaScript
> array... If this is a better way... I'm not shure.
>
> As I wrote Skeeve helped me a lot in a privat email conversation. He
> suggested to use Perl instead of AppleScript. Maybe with an
> AppleScript as frontend.
>
> Benedikt
>
>
> Am 23.01.2008 um 12:57 schrieb Mark J. Reed:
>
> > On Jan 23, 2008 4:52 AM, Benedikt Quirmbach <email@hidden>
> > wrote:
> >> The real csv files have up to 35000 lines and up to 10 items every
> >> line.
> >> Here the handler works endless. As Skeeve said (he testet with 10000
> >> lines) there is a stack overflow.
> >
> > So why are you trying to slurp the whole 35,000-line file into memory
> > as one big list? Can't you just process each line as you read it?
> >
> > --
> > Mark J. Reed <email@hidden>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden