in reply to Read files and convert extracted text to .csvc
If the files are just sequences of 3-line records with nothing else separating the sets, you'll need something like:
my %record; my ( $id, $field ); while (<>) { chomp; if ( /^RECORD:\s+(\d+)/ ) { $id = $1; elsif ( /Field:\s/ ) { $field = $_; elsif ( /MSG#\s ) { $record{$id}{field} = $field; $record{$id}{msg} = $_; } } # now go through the %record set, output to csv...
As for putting stuff into a csv file, Text::CSV will be a big help, and as indicated above, you can install your own copy of the module in your home directory. But maybe your unix system already has it -- try "perldoc Text::CSV" as a shell command, to see if the module there.
(And most unix systems that support multiple users have at least one "sysadmin" person, who will often accept reasonable requests for installing non-core perl modules from CPAN. You do know how to contact your sysadmin, right?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read files and convert extracted text to .csvc
by AnomalousMonk (Archbishop) on May 22, 2010 at 18:33 UTC |