X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=enrich_zips;h=8f51a62b58ebe10b2d8ec5b56d16418b823dc017;hp=28587df1ed948d4d1b2013c9761f89e848f82e54;hb=8d1dd4148a2ed672e53067901d2d823249ff8a6f;hpb=8007a4c9facf5bc62a389461e6ea9c8c63012a2c diff --git a/enrich_zips b/enrich_zips index 28587df..8f51a62 100755 --- a/enrich_zips +++ b/enrich_zips @@ -20,12 +20,16 @@ NOTES Geonames database can be downloaded from http://download.geonames.org/export/zip/US.zip + Add the --believegn flag if you want to believe the Geonames database when it conflicts with patron data. + =cut -my ($db, $makezips, %zips, $warn); -my $result = GetOptions ("db=s" => \$db, - "makezips" => \$makezips, - "warn" => \$warn); +my ($db, $makezips, %zips, $warn, $believegn); +my $result = GetOptions ("db=s" => \$db, + "makezips" => \$makezips, + "warn" => \$warn, + "believegn" => \$believegn); + die "Please specify the location of the Geonames database with --db US.txt\n" . "HINT: You can download it at http://download.geonames.org/export/zip/US.zip" . @@ -65,6 +69,12 @@ while (<>) { } if ($makezips) { + if ($city ne $dbcity || $state ne $dbstate) { + if ($believegn) { + $city = $dbcity; + $state = $dbstate; + } + } print "|" . join("|", ($state, $city, $zip, "1", "", $county)) . "||\n"; } else { print join("\t", ($city, $state, $zip, $county)) . "\n";