in reply to matching datetimestamps and concatenating data where timestamps match from multiple large datafiles
UPDATE: As CountZero points out below, there is a problem with my do {...} blocks, so please check his proposal Re: matching datetimestamps and concatenating data where timestamps match from multiple large datafiles which should run as intended.
It sounds like your data is sorted ascending with respect to time. Under this assumption I propose to use the following idea of a script:
use strict; use warnings; open my $fileA, ... or die; open my $fileB, ... or die; # same with the other files my $lineB = ''; while( my $lineA = <$fileA> ) { chomp $lineA; next unless $lineA =~ m/^\d\.+(\d{2}):(\d{2}):(\d{2})\.+(\d{2})(\d{2 +})(\d{2})\d{2}.abc/; my $dateA = ... ; # construct date from $1, $2 etc do { chomp $lineB; next unless $lineB =~ m/^\d\.+(\d{2}):(\d{2}):(\d{2})\.+(\d{2})(\d +{2})(\d{2})\d{2}.abc/; my $dateB = ... ; # construct date ... next if $dateB < $dateA; # use some date and time library for thes +e comparisons last if $dateB > $dateA; # ... $lineA .= $lineB; } while( $lineB = <$fileB> ); # same with fileC etc... print "$lineA\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: matching datetimestamps and concatenating data where timestamps match from multiple large datafiles
by CountZero (Bishop) on Sep 22, 2013 at 13:57 UTC | |
by hdb (Monsignor) on Sep 22, 2013 at 14:06 UTC | |
by CountZero (Bishop) on Sep 22, 2013 at 14:41 UTC |