Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Need help with arrays and CSVs

by ww (Archbishop)
on Dec 26, 2007 at 21:02 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://659118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-25 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found