Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Need help with arrays and CSVs

by ww (Archbishop)
on Dec 26, 2007 at 21:02 UTC ( #659118=note: print w/replies, xml ) Need Help??


in reply to Re: Need help with arrays and CSVs
in thread Need help with arrays and CSVs

...and if your data is multiline, eg:
this is a field to start with,field2,field3 #,*,field3 of line 2 field1 of line3,and this is the second field of line3,field3 of line3

then replacing the relevant part of the above code with this fragment produces a line of output for each field:

while (<FILE>) { $csv->parse($_); push(@printerstat, $csv->fields); # print @printerstat; } spit(@printerstat); sub spit { for my $field(@printerstat) { print "$field\n"; } }

thusly

this is a field to start with field2 field3 # * field3 of line 2 field1 of line3 and this is the second field of line3 field3 of line3

This also works if some of your fields are void, eg:

,,this is a row with two empty fields

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2021-04-23 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?