Mapping of ZIP codes to FIPS county codes
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 8 commits ahead, 4 commits behind bgruber:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

zip2fips // fip2zips

At work, we keep certain location information indexed by zipcode. Recently, I wanted to feed that data into something that worked with 5-digit FIPS county codes, and was unable to find an easily-parsed table that mapped, however roughly, from one to the other. The best I could find was the CDC's County Cross Reference files, but I realized I needed to do quite a bit of parsing before they were really useful to me. I figured it might be of use to someone else, so here it is.

The fetch_source script downloads the zip files and makes the one "cleanup" change required, to line 1794315 of zipcty4, which originally was missing GA as the state abbreviation. constructs the json dictionary from fips code to state, county and zip code from the zipcty files. The output is in fips2counties_v2.json.

The state_fips.json file was made by hand, where "by hand" means I copy-and-pasted this table and manipulated it in Emacs.