well on the way to having a working cluster database
[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 system("rm -rf $Spot::prefix");
14 Spot->init();
15
16 while (sysread(IN, $buf, 86)) {
17   ($freq,$call,$date,$time,$comment,$spotter) = unpack 'A10A13A12A6A31A14', $buf;
18   $date =~ s/^\s*(\d+)-(\w\w\w)-(19\d\d)$/$1 $2 $3/og;
19   $time =~ s/^(\d\d)(\d\d)Z$/$1:$2 +0000/;
20   $d = str2time("$date $time");
21   $comment =~ s/^\s+//o;
22   if ($d) {
23     Spot->new($freq, $call, $d, $comment, $spotter);
24   } else {
25     print "$call $freq $date $time\n";
26   }
27 }
28
29 close(IN);
30 close(OUT);