Prepare for git repository
[spider.git] / perl / gen_usdb_data.pl
index d4edaafade903da192bfd97716bb7160d488c54c..a59d4340ae931129d48f01825005150b5c00528b 100755 (executable)
@@ -36,15 +36,10 @@ BEGIN {
        $root = "/spider"; 
        $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
 
+       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 DXVars;
 use Archive::Zip qw(:ERROR_CODES);
 use Archive::Zip::MemberRead;
@@ -55,7 +50,7 @@ my $blksize = 1024 * 1024;
 
 STDOUT->autoflush(1);
 
-my $dbrawfn = "$main::data/usdbraw";
+my $dbrawfn = "$main::data/usdbraw.gz";
 
 rename "$dbrawfn.oo", "$dbrawfn.ooo";
 rename "$dbrawfn.o", "$dbrawfn.oo";
@@ -73,7 +68,6 @@ foreach my $argv (@ARGV) {
 }
 
 $gzfh->gzclose;
-print "$ctycount Cities found\n";
 
 exit(0);
 
@@ -96,19 +90,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;
                }