• Post Reply Bookmark Topic Watch Topic
  • New Topic

zip code to city/state database  RSS feed

 
paul wheaton
Trailboss
Posts: 22581
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing that there is a freebie zip code to city/state database out there somewhere. Anybody know where?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
Here's a possibility at the home of good ol' snail mail:
USPS Webtools
The page indicates that all services use XML.
Michael Morris
 
paul wheaton
Trailboss
Posts: 22581
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm,
This could do the trick. The algorithm could take a zip code and see if we have looked that zip code up in the past. If we have, we just use the local stuff. Otherwise, we go get the information from the post office. Not bad!
 
paul wheaton
Trailboss
Posts: 22581
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now my requirements seem to be calling for county information too.
This is some pretty static information. Maybe there is a document somewhere that contains a zip code to county mapping.
In fact, maybe there's a huge text file somewhere that contains zip code, city, state and county mapping.
Anybody know of such a beast?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Paul,
What'd ya mean by freebie? If you're willing to write a little code, you can extract the beast yourself. Here's a URL where you could get everything you want (assuming this site has completely accurate info) :
County/Zip Lookup
The first page presents you with a form with a dropdown of all US States and Possessions. That uses a GET when you push SUBMIT to fetch the next page, which presents you with another page with a dropdown of all the counties in the state you chose. Pushing SUMBIT there gives you a table of all the zipcodes in that county. This also uses GET. So all you have to do is loop thru constructing the encoded URLs and create your database by extacting the info in the tables.
Heres a sample URL to list all the zipcodes in my home county:
<blockquote>code:
<pre>
<a href="http://www.melissadata.com/lookups/CountyZip.asp?statename=Texas&county=48459UPSHUR&B1=Submit</pre rel="nofollow"><hr></blockquote>" target="_blank">http://www.melissadata.com/lookups/CountyZip.asp?statename=Texas&county=48459UPSHUR&B1=Submit[/CODE]
Good luck,
Michael Morris
 
paul wheaton
Trailboss
Posts: 22581
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not bad!
I guess if you run the program once a month, it should get updated regularly enough.
Thanks Michael!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!