[SimBot-commits] CVS: simbot/tools create_zip_db.pl,1.1,1.2
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-05-06 02:30:15
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27403/tools Modified Files: create_zip_db.pl Log Message: Storing the state as a number seems stupid. Let's store abbreviations instead. Index: create_zip_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_zip_db.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- create_zip_db.pl 5 May 2005 23:41:50 -0000 1.1 +++ create_zip_db.pl 6 May 2005 02:29:54 -0000 1.2 @@ -37,6 +37,19 @@ use strict; use CAM::DBF; use DBI; + +my %states = qw( + 01 AL 02 AK 04 AZ 05 AR 06 CA 08 CO 09 CT 10 DE 11 DC + 12 FL 13 GA 15 HI 16 ID 17 IL 18 IN 19 IA 20 KS 21 KY + 22 LA 23 ME 24 MD 25 MA 26 MI 27 MN 28 MS 29 MO 30 MT + 31 NE 32 NV 33 NH 34 NJ 35 NM 36 NY 37 NC 38 ND 39 OH + 40 OK 41 OR 42 PA 44 RI 45 SC 46 SC 47 TN 48 TX 49 UT + 50 VT 51 VA 53 WA 54 WV 55 WI 56 WY + + 60 AS 64 FM 66 GU 68 MH 69 MP 70 PW 72 PR 74 UM 78 VI +); + + # set up the sqlite database my $sqlite_dbh = DBI->connect('dbi:SQLite:dbname=USzip','','', { RaiseError => 1, AutoCommit => 0 }) @@ -78,20 +91,26 @@ for my $row (0 .. $last_row) { my $lat = $cur_row->{'LATITUDE'}; my $long = $cur_row->{'LONGITUDE'}; + my $state = $cur_row->{'STATE'}; + + if($states{$state}) + { $state = $states{$state}; } $lat =~ s/^\s*//; $long =~ s/^\s*//; $insert_row_query->execute($cur_row->{'ZIP_CODE'}, $lat, $long, $cur_row->{'ZIP_CLASS'}, - $cur_row->{'PONAME'}, $cur_row->{'STATE'}, $cur_row->{'COUNTY'}); + $cur_row->{'PONAME'}, $state, $cur_row->{'COUNTY'}); } -print "Done!\nCreating the index..."; -# create the index +print "Done!\nCreating indices..."; $sqlite_dbh->do(<<EOT); CREATE UNIQUE INDEX uszipszip ON uszips (zip); + +CREATE INDEX uszipsstate + ON uszips (state); EOT print " Done!\nCommitting..."; |