Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Bulk Reading and Writing of Large Text Files

by Tux (Monsignor)
on May 23, 2013 at 06:33 UTC ( #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


Comment on Re: Bulk Reading and Writing of Large Text Files
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-31 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls