d5cb4c6e6121341534340fdfbb72a545162126ae
[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
10 sysopen(IN, "../data/DX.DAT", 0) or die "can't open DX.DAT ($!)";
11 open(OUT, ">../data/dxcomma") or die "can't open dxcomma ($!)";
12
13 spot->init();
14
15 while (sysread(IN, $buf, 86)) {
16   ($freq,$call,$date,$time,$comment,$spotter) = unpack 'A10A13A12A6A31A14', $buf;
17   $date =~ s/^\s*(\d+)-(\w\w\w)-(19\d\d)$/$1 $2 $3/og;
18   $time =~ s/^(\d\d)(\d\d)Z$/$1:$2 +0000/;
19   $d = str2time("$date $time");
20   $comment =~ s/^\s+//o;
21   if ($d) {
22     spot->new($freq, $call, $d, $comment, $spotter);
23   } else {
24     print "$call $freq $date $time\n";
25   }
26 }
27
28 close(IN);
29 close(OUT);