Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Reading file into an array and working with it.

by httptech (Chaplain)
on Jun 25, 2000 at 21:10 UTC ( [id://19757]=note: print w/replies, xml ) Need Help??


in reply to Reading file into an array and working with it.

What I would do is use Text::CSV to do the actual parsing, then push each array returned as an array reference onto a master array of locations:
use Text::CSV; my @locations; my $csv = Text::CSV->new(); open (FILE, "locations.csv") or die "Couldn't open location file: $!"; while (<FILE>) { $csv->parse($_); push(@locations, [$csv->fields]); } close FILE;

Replies are listed 'Best First'.
RE: Re: Reading file into an array and working with it.
by davorg (Chancellor) on Jun 26, 2000 at 12:25 UTC

    Might be worth pointing out that on CPAN there is now a Text::CSV_XS which, as its name implies, does the parsing in C code. It is therefore much faster than the pure Perl implementation in Text::CSV.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000
    <http://www.yapc.org/Europe/>
      Hmm, I wonder if DBD::CSV could use it as a backend... and whether it would speed DBD:CSV up, because it is pretty slow.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2025-01-13 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (28 votes). Check out past polls.