calv1n has asked for the wisdom of the Perl Monks concerning the following question:
What needs to be done is to split the file into multiple files based upon the first field such as 06-01-0101:00 So the output file will beUsr1369***12556 06-01-0101:00 1169 <snipped off> 06-01-0101:00 2396 <snipped off> 06-01-0103:12 1169 <snipped off> 06-01-0103:12 2569 <snipped off> 06-01-0301:00 1169 <snipped off> 06-01-0301:00 2396 <snipped off>
I can get the header and one line by usingUsr1369***12556 06-01-0101:00 1169 <snipped off> 06-01-0101:00 2396 <snipped off> Usr1369***12556 06-01-0103:12 1169 <snipped off> 06-01-0103:12 2569 <snipped off> Usr1369***12556 06-01-0301:00 1169 <snipped off> 06-01-0301:00 2396 <snipped off>
Then I get the outputfile handler and domy @filedata = <IFILE_HANDLER>; my $head = shift(@filedata); my $line foreach $line(@filedata);
I haven't the faintest idea of how to group it such that I get one file for each combination of ^\d{2}-\d{2}-\d{4}:\d{2} Would appreciate any help you guys could give.print (OFILE_HANDLER "$head"); print (OFILE_HANDLER "$line"); close (OFILE_HANDLER);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split file based on field
by holli (Abbot) on Jan 10, 2006 at 09:46 UTC | |
by blazar (Canon) on Jan 10, 2006 at 13:40 UTC | |
|
Re: Split file based on field
by McDarren (Abbot) on Jan 10, 2006 at 10:25 UTC | |
|
Re: Split file based on field
by sh1tn (Priest) on Jan 10, 2006 at 10:09 UTC | |
by holli (Abbot) on Jan 10, 2006 at 11:10 UTC | |
by sh1tn (Priest) on Jan 10, 2006 at 12:43 UTC | |
|
Re: Split file based on field
by erniep (Sexton) on Jan 10, 2006 at 12:48 UTC |