LPM: Sorting Big Files

llang at baywestpaper.com llang at baywestpaper.com
Wed Dec 15 09:55:41 CST 1999


This may be the most horribly inefficient way to do it, but if I were faced
with a huge file, a small-ish PC and a time crunch to get it sorted, I'd
probably do this in lieu of having the time to research a really good way:
(No laughing, please - or at least keep it to yourselves  :-}   -- comments
on improvement, however, are welcome)

1.  Parse through the file and create an array of country names, keeping
only the unique ones.
2.  Sort that array.
3.  For each element of that array, parse the file again and pull out the
records that match that country name.

Like I said, it's inefficient, but (for me, anyway) it'd get it done faster
than putting together a really elegant solution.


Loren Lang               Phone:    606-734-0538 x326
Network Administrator         Fax: 606-734-8210
Bay West Paper Corporation    email:     llang at baywestpaper.com

"There is no greater burden than great potential." - Charles Schultz  (the soon-to-be-retired)






Hello, List!

Does anyone have a smooth way of sorting large text files?  (By
"large" I mean "in excess of 1GB" and by "text files" I mean "flat
ASCII database files.")

Here's the task:  I have a text database of a million or so records.
Each record is about 1300 bytes long.  I need to change record
format from fixed-field to delimited, sort the records in country name
order, then output in 10,000 record pieces to sequentially numbered
text files.  I already have routines to change format and output the
file in pieces; it's the sorting part that has me wondering.

Any suggestions are much appreciated.

Thanks!
Janine

(aka "Louisville Girl")









More information about the Lexington-pm mailing list