Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Question about parsing columns when using Text::CSV

by fullermd (Priest)
on Jan 06, 2009 at 15:18 UTC ( [id://734457]=note: print w/replies, xml ) Need Help??


in reply to Question about parsing columns when using Text::CSV

The first bit of help is to see Markup in the Monastery and use <code> tags so the code is readable. Like:

#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $file = '112008.csv'; my $output='112008.txt'; my $csv = Text::CSV->new(); open (CSV, "<", $file) or die $!; open(OUTFILE,">$output") || die "Can't open file $output"; while (<CSV>) { if ($csv->parse($_)) { my @columns = $csv->fields(); printf OUTFILE "@columns\n"; } else { my $err = $csv->error_input; print "Failed to parse line: $err"; } } close CSV;

Lot easier to read and comment on then.

Log In?
Username:
Password:

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

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

    No recent polls found