Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Parsing a large file 80GB .gz file and making an output file with specifice columns in this original file.

by BrowserUk (Pope)
on Jul 16, 2013 at 14:30 UTC ( #1044621=note: print w/ replies, xml ) Need Help??


in reply to Parsing a large file 80GB .gz file and making an output file with specifice columns in this original file.

I think Corion has the right idea, but I'd take it one step further and avoid having the perl script write directly to disk.

I'd do it this way:

gunzip -cd big.tsv.gz | perl -ne"@v=split chr(9),$_; $i=-1; print $v[$i+=3], chr(9) while $i + < @v; print chr(10)" | perl -pe1 > newfile

NB: That's a one-liner wrapped across 3 lines for posting.

The idea is to

  1. Minimise the memory juggling inside the first perl script.

    By avoiding building a second array of the columns you are keeping and then more memory in order to do the join.

  2. Use the pipe buffers between the first perl and the second to buffer the IO and prevent some disk contention.

If you are going to be doing this regularly rather than just as a one-off, it might be worth trying both ways to see which works best on your system.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Parsing a large file 80GB .gz file and making an output file with specifice columns in this original file.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-12-22 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (119 votes), past polls