in reply to merging to databases... Should be easy...
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]; } }
|
|---|