• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading a csv file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Reading a csv file
      • From: Michelle Steiner <email@hidden>
References: 
 >Reading a csv file (From: Ian Cook <email@hidden>)

  • Prev by Date: Re: where are the shell scripts ?
  • Next by Date: Re: where are the shell scripts ?
  • Previous by thread: Reading a csv file
  • Next by thread: Re: Reading a csv file
  • Index(es):
    • Date
    • Thread