add logging of PC92A ip addresses
[spider.git] / perl / dxoldtonew.pl
1 #!/usr/bin/perl
2 #
3 # convert an AK1A DX.DAT file to comma delimited form
4 #
5 # PLEASE BE WARNED:
6 #
7 # This routine is really designed for archive data. It will create and add to 
8 # standard DXSpider spot files. If those spot files already exist (because you
9 # were running DXSpider at the same time as collecting this 'old' data) then
10 # this will simply append the data onto the end of the appropriate spot file
11 # for that day. This may then give strange 'out of order' results when viewed
12 # with the show/dx command
13 #
14 #
15 #
16 # Copyright (c) 1998-2003 Dirk Koopman G1TLH
17 #
18
19 # search local then perl directories
20 BEGIN {
21         # root of directory tree for this system
22         $root = "/spider"; 
23         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
24         
25         unshift @INC, "$root/perl";     # this IS the right way round!
26         unshift @INC, "$root/local";
27 }
28
29 use DXUtil;
30 use Spot;
31 use Prefix;
32
33 $ifn = "$root/data/DX.DAT";
34 $ifn = shift if @ARGV;
35 print "Using: $ifn as input... \n";
36
37 sysopen(IN, $ifn, 0) or die "can't open $ifn ($!)";
38
39 Prefix::init();
40 Spot::init();
41
42 while (sysread(IN, $buf, 86)) {
43   ($freq,$call,$date,$time,$comment,$spotter) = unpack 'A10A13A12A6A31A14', $buf;
44 #  printf "%-13s %10.1f %s %s by %s %s\n", $call, $freq, $date, $time, $spotter, $comment;
45   
46   $dt = cltounix($date, $time);
47   $comment =~ s/^\s+//o;
48   if ($dt ) {
49           my @spot = Spot::prepare($freq, $call, $dt, $comment, $spotter);
50           Spot::add(@spot);
51   } else {
52     print "ERROR: $call $freq $date $time by $spotter $comment\n";
53   }
54 }
55
56 close(IN);