• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

zip code to city/state database

 
Trailboss
Posts: 23453
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23453
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23453
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23453
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic