X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fgen_usdb_data.pl;h=e8ced1f0970f6308231902b0bec685b45aa317f2;hb=d41556c82d7af6d68d9d659bd486be775f82295d;hp=d4edaafade903da192bfd97716bb7160d488c54c;hpb=1ddd21105b4fdf68756a8676a58105927254d386;p=spider.git diff --git a/perl/gen_usdb_data.pl b/perl/gen_usdb_data.pl index d4edaafa..e8ced1f0 100755 --- a/perl/gen_usdb_data.pl +++ b/perl/gen_usdb_data.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Something to create my subset of the US call book data, # in my flat file form, either from the main data base or @@ -6,24 +6,24 @@ # # You can get the main database from: # -# http://wireless.fcc.gov/uls/data/complete/l_amat.zip +# https://data.fcc.gov/download/pub/uls/complete/l_amat.zip # # The daily data bases are available as a set of seven from here:- # -# http://wireless.fcc.gov/uls/data/daily/l_am_sat.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_sun.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_mon.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_tue.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_wed.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_thu.zip -# http://wireless.fcc.gov/uls/data/daily/l_am_fri.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_sat.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_sun.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_mon.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_tue.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_wed.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_thu.zip +# https://data.fcc.gov/download/pub/uls/daily/l_am_fri.zip # # this program expects one or more zip files containing the call book # data as arguments. # # Copyright (c) 2002 Dirk Koopman G1TLH # -# $Id$ +# # use strict; @@ -36,26 +36,25 @@ BEGIN { $root = "/spider"; $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'}; + mkdir "$root/local_data", 02777 unless -d "$root/local_data"; + + unshift @INC, "$root/perl"; # this IS the right way round! unshift @INC, "$root/local"; } -use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); -$main::build += $VERSION; -$main::branch += $BRANCH; +use SysVar; -use DXVars; use Archive::Zip qw(:ERROR_CODES); use Archive::Zip::MemberRead; use IO::File; use Compress::Zlib; +use DXUtil; my $blksize = 1024 * 1024; STDOUT->autoflush(1); -my $dbrawfn = "$main::data/usdbraw"; +my $dbrawfn = localdata("usdbraw.gz"); rename "$dbrawfn.oo", "$dbrawfn.ooo"; rename "$dbrawfn.o", "$dbrawfn.oo"; @@ -73,7 +72,6 @@ foreach my $argv (@ARGV) { } $gzfh->gzclose; -print "$ctycount Cities found\n"; exit(0); @@ -81,7 +79,7 @@ sub handleEN { my ($zip, $argv) = @_; my $mname = "EN.dat"; - my $ofn = "$main::data/$mname"; + my $ofn = localdata($mname); print " Handling EN records, unzipping"; if ($zip->extractMember($mname, $ofn) == AZ_OK) { my $fh = new IO::File "$ofn" or die "Cannot open $ofn $!"; @@ -96,19 +94,20 @@ sub handleEN $l =~ s/[\r\n]+$//; my ($rt,$usi,$ulsfn,$ebfno,$call,$type,$lid,$name,$first,$middle,$last,$suffix, $phone,$fax,$email,$street,$city,$state,$zip,$pobox,$attl,$sgin,$frn) = split /\|/, $l; - - my $rec = uc join '|', $call,$city,$state if $city && $state; - $buf .= "$rec\n"; - if (length $buf > $blksize) { - $gzfh->gzwrite($buf); - undef $buf; + +# print "ERR: $l\n" unless $call && $city && $state; + + if ($call && $city && $state) { + my $rec = uc join '|', $call,$city,$state if $city && $state; + $buf .= "$rec\n"; + if (length $buf > $blksize) { + $gzfh->gzwrite($buf); + undef $buf; + } + $count++; } - my $c = uc "$city|$state"; - $count++; - } - if (length $buf > $blksize) { - $gzfh->gzwrite($buf); } + $gzfh->gzwrite($buf) if length $buf; print ", $count records\n"; $fh->close; }