• 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: tab delimited data file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tab delimited data file


  • Subject: Re: tab delimited data file
  • From: Steve Roy <email@hidden>
  • Date: Wed, 25 Jun 2003 21:45:49 -0400

Rick Norman <email@hidden> 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.

Well just for fun, here's my solution.

set theText 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 allEntries to every paragraph of theText
set theUniqueTokens to {}
set theFilteredEntries to {}
set AppleScript's text item delimiters to {tab}
repeat with anEntry in allEntries
set theToken to text item 2 of anEntry as string
if theUniqueTokens does not contain theToken then
set theUniqueTokens to theUniqueTokens & {theToken}
set theFilteredEntries to theFilteredEntries & {anEntry as string}
end if
end repeat

set AppleScript's text item delimiters to {return}
theFilteredEntries as string

Steve

--
Steve Roy <email@hidden>
Personal homepage: <http://homepage.mac.com/sroy>
Projects homepage: <http://www.roydesign.net>
_______________________________________________
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.

References: 
 >tab delimited data file (From: Rick Norman <email@hidden>)

  • Prev by Date: Re: Get position of item in list
  • Next by Date: Re: Script Editor 2.0 (beta II)
  • Previous by thread: Re: tab delimited data file
  • Next by thread: Re: tab delimited data file
  • Index(es):
    • Date
    • Thread