got the prefix code working quite well, changed a few country codes.
[spider.git] / perl / dxoldtonew.pl
1 #!/usr/bin/perl
2 #
3 # convert an Ak1a DX.DAT file to comma delimited form
4 #
5 #
6
7 use Date::Parse;
8 use Spot;
9 use Prefix;
10
11 sysopen(IN, "../data/DX.DAT", 0) or die "can't open DX.DAT ($!)";
12 open(OUT, ">../data/dxcomma") or die "can't open dxcomma ($!)";
13
14 Prefix::load();
15
16 $fn = Spot::prefix();
17 system("rm -rf $fn/*");
18
19 while (sysread(IN, $buf, 86)) {
20   ($freq,$call,$date,$time,$comment,$spotter) = unpack 'A10A13A12A6A31A14', $buf;
21   $d = $date =~ s/^\s*(\d+)-(\w\w\w)-(19\d\d)$/$1 $2 $3/o;
22   $t = $time =~ s/^(\d\d)(\d\d)Z$/$1:$2 +0000/o;
23   $dt = undef;
24   $dt = str2time("$date $time") if $d && $t;
25   $comment =~ s/^\s+//o;
26   if ($dt ) {
27     Spot::add($freq, $call, $dt, $comment, $spotter);
28   } else {
29     print "$call $freq $date $time\n";
30   }
31 }
32
33 close(IN);
34 close(OUT);