perl midasproc2.pl midas_wxhrly_199901-199912.txt 19260 "1999-12-15 11:00"
####
1999-01-01 00:00, EGPK, ICAO, METAR, 1, 1006, 1001, , , 120, 13, 00, , , , , , , , , 1000, , 1, , 96, 6, , $
1999-01-01 00:00, EGSS, ICAO, METAR, 1, 484, 1001, , , 130, 8, 00, , , , , , , , , 1000, , 1, , 120, , , , $
1999-01-01 01:00, 03002, WMO, SYNOP, 1, 12, 1011, 4, 6, 160, 20, , , , , , , , , 20, 440, 1004.1, 7, , 24, $
####
#!/usr/bin/perl
use strict;
use warnings;
my ($record, $date, $outfile, $station, $sstation, $linecnt, $pcntg, @values);
print "Processing \"$ARGV[0]\"...\n";
$date = $ARGV[2];
$station = $ARGV[1];
$outfile = $date.".txt";
$outfile =~ s/ /-/;
print "For Date: $date and Station: $station\n\n";
$linecnt = `wc -l < $ARGV[0]`;
open (INFILE, $ARGV[0]);
open (OUTFILE, ">>", $outfile);
while () {
$pcntg = int (($. / $linecnt ) * 100) ;
print "$pcntg %\r";
chomp();
$record = $_;
@values = split (',',$record);
$sstation = $values[5];
$sstation =~ s/ //g;
if ($values[0] eq $date && $sstation eq $station ) {
print OUTFILE $record."\n";
# print "xx".$values[5]."xx\n";
print "Record written to $outfile...\n";
last;
}
}
print "\nFinished\n";
close (INFILE);
close (OUTFILE);