comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: comparing and concatenating arrays...please help!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: comparing and concatenating arrays...please help!! [message #37576 is a reply to message #37573] Fri, 09 January 2004 01:50 Go to previous messageGo to previous message
wmconnolley is currently offline  wmconnolley
Messages: 106
Registered: November 2000
Senior Member
Martin Doyle <m.doyle@uea.ac.uk> wrote:
> My files are _huge_. File 1 is about 250000 lines and file2 about half
> that. which is why my code was taking about 4 days!

Here is my initial entry in the obfusticated solution using perl.
However, I think I misread you because in whats below I've assumed
that dates for each ob exist in each file. If you only want output
when both match, and throw away what doesn't have equiv's in both files,
then use the alternative last line.

#!/bin/perl

@f1=split("\n",`cat f1`);
@f2=split("\n",`cat f2`);

for (@f1) { ($y,$m,$d,$h,$r)=(/(....) (..) (..) (..) (.*)/); $f1{"$y $m $d $h"}=$r };
for (@f2) { ($y,$m,$d,$h,$r)=(/(....) (..) (..) (..) (.*)/); $f2{"$y $m $d $h"}=$r };

for $k (sort keys %f1) { print "$k $f1{$k} $f2{$k}\n" };

# Alternative output line
# for $k (sort keys %f1) { if ($f1{$k} and $f2{$k} ) { print "$k $f1{$k} $f2{$k}\n" } };

This should be fast (a few mins at most) if all the data fits into your memory at
once, as it ought to. You can write "reverse" in front of sort if you want it
backwards.

-W.

--
William M Connolley | wmc@bas.ac.uk | http://www.antarctica.ac.uk/met/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself
I'm a .signature virus! copy me into your .signature file & help me spread!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Passing from from IDL to external lib (DLM)
Next Topic: Re: Problem masking multiple regions.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 04:21:22 PDT 2025

Total time taken to generate the page: 0.79521 seconds