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.

In reply to Re: Parsing a large file 80GB .gz file and making an output file with specifice columns in this original file. by BrowserUk
in thread Parsing a large file 80GB .gz file and making an output file with specifice columns in this original file. by pillaipraveen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.