3 # Something to create my subset of the US call book data,
4 # in my flat file form, either from the main data base or
5 # else the daily updates.
7 # You can get the main database from:
9 # https://data.fcc.gov/download/pub/uls/complete/l_amat.zip
11 # The daily data bases are available as a set of seven from here:-
13 # https://data.fcc.gov/download/pub/uls/daily/l_am_sat.zip
14 # https://data.fcc.gov/download/pub/uls/daily/l_am_sun.zip
15 # https://data.fcc.gov/download/pub/uls/daily/l_am_mon.zip
16 # https://data.fcc.gov/download/pub/uls/daily/l_am_tue.zip
17 # https://data.fcc.gov/download/pub/uls/daily/l_am_wed.zip
18 # https://data.fcc.gov/download/pub/uls/daily/l_am_thu.zip
19 # https://data.fcc.gov/download/pub/uls/daily/l_am_fri.zip
21 # this program expects one or more zip files containing the call book
24 # Copyright (c) 2002 Dirk Koopman G1TLH
31 # make sure that modules are searched in the order local then perl
33 # root of directory tree for this system
37 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
39 mkdir "$root/local_data", 02777 unless -d "$root/local_data";
41 unshift @INC, "$root/perl"; # this IS the right way round!
42 unshift @INC, "$root/local";
47 use Archive::Zip qw(:ERROR_CODES);
48 use Archive::Zip::MemberRead;
53 my $blksize = 1024 * 1024;
57 my $dbrawfn = localdata("usdbraw.gz");
59 rename "$dbrawfn.oo", "$dbrawfn.ooo";
60 rename "$dbrawfn.o", "$dbrawfn.oo";
61 rename "$dbrawfn", "$dbrawfn.o";
62 my $gzfh = gzopen($dbrawfn, "wb") or die "Cannot open $dbrawfn $!";
66 foreach my $argv (@ARGV) {
67 my $zip = new Archive::Zip($argv) or die "Cannot open $argv $!\n";
68 print "Doing $argv\n";
69 handleEN($zip, $argv);
70 handleAM($zip, $argv);
71 handleHS($zip, $argv);
80 my ($zip, $argv) = @_;
82 my $ofn = localdata($mname);
83 print " Handling EN records, unzipping";
84 if ($zip->extractMember($mname, $ofn) == AZ_OK) {
85 my $fh = new IO::File "$ofn" or die "Cannot open $ofn $!";
93 while (my $l = $fh->getline) {
95 my ($rt,$usi,$ulsfn,$ebfno,$call,$type,$lid,$name,$first,$middle,$last,$suffix,
96 $phone,$fax,$email,$street,$city,$state,$zip,$pobox,$attl,$sgin,$frn) = split /\|/, $l;
98 # print "ERR: $l\n" unless $call && $city && $state;
100 if ($call && $city && $state) {
101 my $rec = uc join '|', $call,$city,$state if $city && $state;
103 if (length $buf > $blksize) {
104 $gzfh->gzwrite($buf);
110 $gzfh->gzwrite($buf) if length $buf;
111 print ", $count records\n";
116 print "EN missing in $argv\n";