3 # convert a DXSpider Spot file to csv format
5 # usage: spot2csv.pl <filename> ...
7 # Copyright (c) 2001 Dirk Koopman G1TLH
11 # make sure that modules are searched in the order local then perl
15 # root of directory tree for this system
16 use vars qw($root $is_win);
18 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
20 unshift @INC, "$root/perl"; # this IS the right way round!
21 unshift @INC, "$root/local";
23 $is_win = ($^O =~ /^MS/ || $^O =~ /^OS-2/) ? 1 : 0; # is it Windows?
28 die "usage: spot2csv.pl <filename> ....\n" unless @ARGV;
30 my $crnl = $is_win ? "\015\012" : "\012";
33 unless (open IN, $_) {
34 print STDERR "cannot open $_ $!\n";
39 s/([\%\"\'\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
40 my @spot = split '\^';
41 my $date = unpad cldate($spot[2]);
42 my $time = unpad ztime($spot[2], 1);
43 print "$spot[0]\t\"$spot[1]\"\t\"$date\"\t$time\t";
44 print $spot[3] ? "\"$spot[3]\"\t" : "\t";
45 print "\"$spot[4]\"\t$spot[5]\t$spot[6]\t\"$spot[7]\"$crnl";