Re: tab delimited data file
Re: tab delimited data file
- Subject: Re: tab delimited data file
- From: Rick Norman <email@hidden>
- Date: Wed, 25 Jun 2003 14:48:12 -0500
That's great except for the fact that each data file is 1000 records with 35
fields in each record. In this example would I have to paste the data file
into the script? The way I had thought of doing it (just not sure how to
write it) is to take record 1 and store the number being compared in a list
(which would be "10" in this case) and write record one to a new file and
then if that number "10" is encountered again it will be ignored, but
continue with every new unique number throughout the file. Hope that makes
sense.
Thanks,
Rick Norman
>
From: John Delacour <email@hidden>
>
Date: Wed, 25 Jun 2003 20:38:51 +0100
>
To: <email@hidden>
>
Subject: Re: tab delimited data file
>
>
At 1:16 pm -0500 25/6/03, Rick Norman wrote:
>
>
> If you had several tab delimited data files with 1000 records in each and
>
> one of the data fields held a particular number that may repeat several
>
> times and you wanted to reduce the 1000 records down to just one record each
>
> by that particular number, how would you do it. A visual sample follows.
>
>
>
Without resorting to writing and reading a file (which is probably
>
the way you'll want to do it) here's a way to work with your sample.
>
>
>
set _done to {}
>
set _lineending to return -- or ascii character 10 if that's what you need
>
set my text item delimiters to tab
>
set _paras to {}
>
set _text to "Bob 10 July, 4
>
Ted 10 July, 4
>
Carol 09 July, 4
>
Alice 09 July, 4
>
John 09 July, 4
>
Jane 02 July, 4
>
Fred 02 July, 4
>
Jim 01 July, 4"
>
set i to 0
>
repeat with _line in paragraphs of _text
>
set _number to second text item in _line as number
>
if _done does not contain _number then
>
set end of _paras to _line as Unicode text
>
set end of _done to _number
>
end if
>
end repeat
>
set my text item delimiters to _lineending
>
set _ecotext to _paras as Unicode text
>
set my text item delimiters to ""
>
_ecotext
>
>
>
JD
>
>
>
>
>
>
>
.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.