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

Uniq fields [was: tab delimited data file]


  • Subject: Uniq fields [was: tab delimited data file]
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Wed, 25 Jun 2003 17:37:24 -0400

On Wednesday, June 25, 2003, at 04:36 PM, Rick Norman wrote:

I've been using M$ Excel and was hoping to find a way around it. I wouldn't
object to using perl but I would not even know where to start. Is this one
of those task that really isn't appropriate for AS or maybe I should say is
better suited with some other language? I believe that I could finally hack
out something, there is just the immediate time constraint (production, you
understand). It seems that reading in the records and storing the numeric
value being compared and using that to compare the following records and
determining whether or not they should be written out to the resulting file
is more than feasible. Thoughts, concerns?
Thanks,
Rick Norman


I would probably do it in python, but in whatever language you want to:

split fields on delimiter

either sort by the desired unique field, so non-unique values will be adjacent and
then throw out duplicates on a second pass

or stuff records into a dictionary indexed by the unique id, and catch duplicates in single pass.

( This is assuming that you don't need to preserve the input order in the output.
If you do, then you need to save and input record count and sort on that before output. )


Applescript doesn't natively have dicts/assoc. arrays or do sorts.
If you've got an OSAX handy that does one or the other, then you can do it in AppleScript.

The other option that comes to mind -- totally untried -- is to use AppleScript Studio and
script calls to an objective-C NSDictionary object. (obviously, an OSX only solution)


The usual shell method is to pipe output to sort and then to uniq, but uniq can skip leading fields or characters,
but not trailing ones, so you would have to reorder your data fields, which is probably more of a pain than
it's worth.


-- Steve Majewski
_______________________________________________
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: 
 >Re: tab delimited data file (From: Rick Norman <email@hidden>)

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