Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: CSV file to C file conversion using perl

by Anonymous Monk
on Jun 19, 2014 at 17:37 UTC ( #1090501=note: print w/ replies, xml ) Need Help??


in reply to CSV file to C file conversion using perl

Something like this might work (won't necessarily work, but should give you an idea)

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 }


Comment on Re: CSV file to C file conversion using perl
Download Code
Re^2: CSV file to C file conversion using perl
by Anonymous Monk on Jun 19, 2014 at 17:48 UTC
    Damn, I forgot. You must delete END from the end.  s/\A \s+ | \s* (END)? \z//gx
Re^2: CSV file to C file conversion using perl
by sundialsvc4 (Abbot) on Jun 19, 2014 at 19:55 UTC

    Anonymous Brother, prithee, what is FLASH() ??

      FLASH_CONFIGURATION_DEVICE from the original post :)
Re^2: CSV file to C file conversion using perl
by Anonymous Monk on Jun 20, 2014 at 05:40 UTC

    Hi Monk

    Thanks for the initial help. I have started writing the perl script based on your suggestion and will get back to you once I am done and if I face any issue i will post it here.

Re^2: CSV file to C file conversion using perl
by gopsi1234 (Initiate) on Jun 20, 2014 at 05:44 UTC

    Hi Monk

    Thanks for the initial help. I have started writing the perl script based on your suggestion and will get back to you once I am done and if I face any issue i will post it here.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-07-04 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls