Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: parallel reading

by roboticus (Chancellor)
on May 09, 2006 at 12:40 UTC ( #548192=note: print w/ replies, xml ) Need Help??


in reply to parallel reading

azaria

If you're on a *nix box, you could use the paste command, e.g.:

paste A B C
But since you asked on perlmonks, you could try something like this (terrible) program:

#!/usr/bin/perl -w use strict; use warnings; open(A,"<A") or die "Can't open A!"; open(B,"<B") or die "Can't open B!"; open(C,"<C") or die "Can't open C!"; my @a = <A>; my @b = <B>; my @c = <C>; while (1) { my $fl=0; my $aa = shift @a || ""; my $bb = shift @b || ""; my $cc = shift @c || ""; chomp $aa; chomp $bb; chomp $cc; print $aa, $bb, $cc, "\n"; next if $#a + $#b + $#c; last; }
--roboticus


Comment on Re: parallel reading
Select or Download Code
Re^2: parallel reading
by azaria (Beadle) on May 09, 2006 at 12:57 UTC
    First thanks for your reply. The example I gave is very shortly. The size of the input files might be change and might be big, so i guess it might influence the memory ? azaria

      In that case I wouldn't slurp in the files all at once. My solution is one that doesn't, copes with a different number of lines per file, and with an arbitrary number of files passed on the cmd line. Shameless self ad terminated! ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-04 17:22 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 (60 votes), past polls