With the files at 500MB each, unless you have a machine with a lot of memory, thats a lot to read into a hash.
If the rows are in any given order you could exploit that. If not then if you first sorted them with
tail +2 d1.dat > d1.sorted
tail +2 d2.dat > d2.sorted
The tail +2 just removes the header line from each. You can then merge them with
open(D1,"<d1.sorted");
open(D2,"<d2.sorted");
my $d1 = "v1 v2 v3";
my $d2 = "t1 t2 t3";
my ($d1k,$d2k)=('','');
for(;;) {
my $c = $d1k cmp $d2k
or print join(" ", split(/\s+/,$d1), (split(/\s+/, $d2))[2]),"\n";
if ($c <= 0) {
last unless defined($d1 = <D1>);
$d1k = ($d1 =~ /^(\d+\s+\d+)/)[0];
}
if ($c >= 0) {
last unless defined($d2 = <D2>);
$d2k = ($d2 =~ /^(\d+\s+\d+)/)[0];
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.