fix sending msgs to g1tlh-2 (and not to g1tlh, - and 2)
[spider.git] / perl / spot2csv.pl
1 #!/usr/bin/perl -w
2 #
3 # convert a DXSpider Spot file to csv format
4 #
5 # usage: spot2csv.pl <filename> ...
6 #
7 # Copyright (c) 2001 Dirk Koopman G1TLH
8 #
9 # $Id$
10
11
12 # make sure that modules are searched in the order local then perl
13 use DXUtil;
14
15 use strict;
16
17 die "usage: spot2csv.pl <filename> ....\n" unless @ARGV;
18
19 for (@ARGV) {
20         unless (open IN, $_) {
21                 print STDERR "cannot open $_ $!\n";
22                 next;
23         }
24         while (<IN>) {
25                 chomp;
26                 s/([\%\"\'\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
27                 my @spot =  split '\^';
28                 my $date = cldate($spot[2]);
29                 my $time = ztime($spot[2], 1);
30                 print "$spot[0]\t\"$spot[1]\"\t\"$date\"\t$time\t";
31                 print $spot[3] ? "\"$spot[3]\"\t" : "\t";
32                 print "\"$spot[4]\"\t$spot[5]\t$spot[6]\t\"$spot[7]\"\r\n";
33         }
34         close IN;
35 }
36
37
38
39