Re: Importing/parsing CSV files
Re: Importing/parsing CSV files
- Subject: Re: Importing/parsing CSV files
- From: T&B <email@hidden>
- Date: Thu, 7 Dec 2006 10:05:32 +1100
Hi Koenig,
Thanks for your feedback and ideas on this.
- 1 - are you sure that the line separator would always be linefeed ?
No. That's why I've made the newLineString an argument that can be
set when calling the handler:
I've made separatorString, quoteString and newLineString to be
arguments so they can be varied with each call
CsvToListClassed(csvText, separatorString, quoteString,
newLineString)
It's linfeed in UNIX but is return in "old fashioned" mac documents
and it may be return + linefeed in windows documents.
and in other files, such as a batch of SQL Insert statements, the
newLineString is even more complicated, such as:
);
INSERT INTO Table VALUES(
- 2 - you use the "property trick" for one list, not for others.
Is it a deliberate choice or is it simply that you "forgot" to use
it ?
I used it for the list that splits up the entire text (delimited by
quote characters), and so is the biggest and most probably has the
most number of items. I may yet move some of the other lists into
script object properties, after I've tested that the current output
is correct and only if testing shows that moving those to script
objects actually makes a speed difference.
- 3 - I like to gather definitions in a single instruction but I
don't know if it fasten the treatment.
Here are two samples:
set {parsedList, valueList} to {{}, {}}
set {oldDelimiters, text item delimiters} to {text item delimiters,
quoteString & quoteString}
Yes, I've seen a few people use compound lists in a set statement. I
personally don't like it since I think it detracts from one of
AppleScript's greatest strengths: readability. I do, however use it
where it adds to readability or where the class makes sense, such as
for colors:
set {objectRed, objectGreen, objectBlue} to objectColor
I haven't seen any evidence that setting variables to values one at a
time or via one compound list gives a speed advantage.
Thanks again for your input,
Tom
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden