Importing/parsing CSV files
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