From 8d1dd4148a2ed672e53067901d2d823249ff8a6f Mon Sep 17 00:00:00 2001 From: Ben Ostrowsky Date: Wed, 20 Jul 2011 13:05:17 +0000 Subject: [PATCH] Added --belivegn flag to believe Geonames over patron data where they conflict --- enrich_zips | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) 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"; -- 1.7.2.5