in reply to CSV file to C file conversion using perl
use strict; use warnings; $/ = 'END'; # see perldoc -v '$/' open my $infile, '<', '/NAME/OF/FILE.csv' or die; open my $outfile, '>', '/NAME/OF/FILE.c' or die; while ($infile) { s/\A \s+ | \s+ \z//gx; # delete leading and trailing whitespace my %record = split /\n|,/; # this is brittle, tweak as necessary # now do something with the record, for example... print $outfile "${record{memid}, FLASH(${record{size}})" # etc }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV file to C file conversion using perl
by Anonymous Monk on Jun 19, 2014 at 17:48 UTC | |
|
Re^2: CSV file to C file conversion using perl
by locked_user sundialsvc4 (Abbot) on Jun 19, 2014 at 19:55 UTC | |
by Anonymous Monk on Jun 19, 2014 at 21:06 UTC | |
|
Re^2: CSV file to C file conversion using perl
by Anonymous Monk on Jun 20, 2014 at 05:40 UTC | |
|
Re^2: CSV file to C file conversion using perl
by gopsi1234 (Initiate) on Jun 20, 2014 at 05:44 UTC |