Re: Reading a csv file
Re: Reading a csv file
- Subject: Re: Reading a csv file
- From: Andrew Oliver <email@hidden>
- Date: Wed, 09 Feb 2005 02:06:29 -0800
On 2/9/05 1:40 AM, "Ian Cook" <email@hidden> wrote:
> Hi, I'm trying to read in a csv file into a list array in my
> applescript. I've achieved it using a TAB delimited file, but with a
> comma delimited file, any commas within a text item are being treated
> as item delimiters too. Therefore...
>
[snip]
Interesting problem. My first instinct was to walk the list looking for any
item with a single quote in it and merge it with the following items up to
and including the next single quote, but that's inefficient, so I thought a
little harder and came up with:
-- in lieu of reading a file I'm going to define the string here
-- replace with your code to read lines of the file
set theSource to "453.25, \"Large, red car\""
-- here's the magic
run script "{" & theSource & "}"
--> { 453.25, "Large, red car" }
'run script' takes a text object and executes it as AppleScript. By
formatting the input line as a text representation of a list in AppleScript
and 'running' it, you get a properly formatted, correctly delimited list.
Andrew
:)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden