Why do you want to process all the records of one type first rather than build 9 arrays as you move through the file and then sort and output then at the end?
I think the missing peices of information from your question are:
a) How big is the input file?
b) Is the input file pre-sorted by the first field? ie. will all the "5 x x x x x x x x" lines be contiguous in the input file?
If the input file is not pre-sorted and especially if it is large, then it would probably be faster to use the system utility to pre-sort the input file, or a copy of it if you need to preserve the original.
If your reasons for doing one record type at a time is because each subset if very large, then it may well be quicker to process the input file to 9 output files in one pass and then either reload the 9 files sort and output again, or use the sort utility on them.
A clear picture of the scale of the problem would make the choice of solution easier.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How can I read multiple lines starting with the same number and put in to a nested array and print it to a file?
by Anonymous Monk on Jun 24, 2002 at 07:55 UTC | |
by BrowserUk (Patriarch) on Jun 24, 2002 at 08:54 UTC |