• 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
Importing/parsing CSV files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Importing/parsing CSV files


  • Subject: Importing/parsing CSV files
  • From: T&B <email@hidden>
  • Date: Thu, 07 Sep 2006 13:07:53 +1000

Hi,

Does anyone have a handler for import a CSV (comma separated value) file into an AppleScript list? I need to allow for full CSV spec, such as values which contain quotes, and commas within quotes, or return/linefeed within quotes.

For example, this raw CSV text:

"First Name","Last Name",Age,Phone
Mickey,Mouse,65,5555 5555
"Hewy, Dewy and Lewy",Duck,
Daisy,Duck
formally Chick,62,"5555 7777, ext 234"
Donald,Duck,64,"5555 7777, ext 235"

Should become this list (where \r is a return or linefeed):

{{"First Name","Last Name","Age","Phone"},
{"Mickey","Mouse","65","5555 5555"},
{"Hewy, Dewy and Lewy","Duck",""},
{"Daisy","Duck\rformally Chick","62","5555 7777, ext 234"},
{"Donald","Duck","64","5555 7777, ext 235"}}

Which visually looks like this (in monospaced font):

First Name           Last Name       Age    Phone
Mickey               Mouse           65     5555 5555
Hewy, Dewy and Lewy  Duck
Daisy                Duck            62     5555 7777, ext 234
                    formally Chick
Donald               Duck            64     5555 7777, ext 235

So, does anyone have or know of a reliable AppleScript routine to do this?
Thanks,
Tom

_______________________________________________
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: Importing/parsing CSV files
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Identifying concurrent processes launched by applescript
  • Next by Date: how choose menu item of pop up button? in Tiger
  • Previous by thread: How do I loop through Indesign Button behaviors?
  • Next by thread: Re: Importing/parsing CSV files
  • Index(es):
    • Date
    • Thread