Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Bulk Reading and Writing of Large Text Files

by Tux (Canon)
on May 23, 2013 at 06:33 UTC ( [id://1034880]=note: print w/replies, xml ) Need Help??


in reply to Bulk Reading and Writing of Large Text Files

This looks like (malformed: spaces) CSV data to me. Splitting the lines, however simple it may look right now, seldom is the correct way to deal with that kind of data. Use Text::CSV_XS or Text::CSV:

use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, allow_whitespace => 1, aut +o_diag => 1 }); my $fs = -s $ARGV[0] or die "Empty input file"; open my $fh, "<", $ARGV[0]; while (my $row = $csv->getline ($fh)) { print int (100 * tell ($fh) / $fs), "%%\r"; my $sstation = $row->[5]; ...

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

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

    No recent polls found