Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Best method of munging CSV data - using Text::CSV::Simple?

by Scott7477 (Chaplain)
on Feb 06, 2007 at 00:11 UTC ( [id://598458]=note: print w/replies, xml ) Need Help??


in reply to Re: Best method of munging CSV data - using Text::CSV::Simple?
in thread Best method of munging CSV data - using Text::CSV::Simple?

Here is my code that uses Text::CSV::Simple; the goal was to parse a NYSE price list from the Wall Street Journal.
use strict; use Text::CSV::Simple; #usage wsj2csv AMEX091806.txt my ($filename) = shift; print $filename."\n"; print "What is the trading date(MMDDYY)?"; my $traddt = <STDIN>; print $traddt."\n"; my $parser = Text::CSV::Simple->new; $parser->want_fields(1, 2, 3, 4, 5, 6, 8); my @data = $parser->read_file($filename); my $datalines = @data; print $datalines."is number of rows.\n"; for my $row(@data) { my @line = @$row; foreach my $row1(@line) { print $row1.","; } print "\n"; }

I intend to add more functionality to this; but this thread was helpful to me in getting the parser to work

Log In?
Username:
Password:

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

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

    No recent polls found