Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting duplicate records in one file

Status
Not open for further replies.

troyarch

MIS
Mar 12, 2003
29
US
I am trying to delete all of the records in one file that have duplicate primary fields (i.e. SSN). The file will have about 300 records.

Is there a standard way to "de-dupe" the files?

Thanks.
Troy
 
Is it a flat text file? What's its format?

The easiest way to do anything like that is to load each record into a hash, with the unique attribute as the hash key. Then just dump the hash back to a file again and you're done. We'll need more info to be more specific. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
In the *x world or with, eg, cygwin, it's easy to
[tt] `sort -u -o $file $file`;[/tt]
rather than reinvent a wheel. "As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top