My problem is that I have a file with thousands of cities and I want to map city names to (Metropolitan Statistical Areas and the MSA equivalent for non-US cities. There have been a bunch of posts here on similar questions. I'm using Python if that helps (ie in case there is a python package available similar to how the googlemaps python package works...)
Mapping Cities to Zip Codes. There is a good answer here that provides a csv with zip codes for every city in the US. But because the census data is published mapping US counties to MSA's, instead of US cities, I would still need to find a way to map back from zip codes to US cities.
Database of US Cities to MSA This is essentially my question (at least the US portion), but it was not answered to the satisfaction of the poster, or my question.
Google's Geocoding Developer Site The Google Geocoding developer's site has a useful CSV that has some US cities mapped to a Google Metro Region code. The problem is that it is not MSA. The old Google csv, downloadable here does not say how the metro coding system was created. The site also has a link to the new Google coding system based on Nielsen's DMA (designated market area) coding system.
I'm really just looking for a csv file that has city, state (if US), country, region code. Where region code is based on well-regarded standard (the US Census Bureau's MSA would be ideal for US cities, and having non-US country's census classifications for non-US cities would be ideal too). Does such a file exist? Alternatively, is there a python package that connects to some database such that I run my script on my input file and it outputs the corresponding region code?
Thanks very much!
ANSWER
For anyone interested, here is a pretty good file that maps US cities to counties: http://www.census.gov/statab/ccdb/ccdbcityplace.html
I was on the hunt for a similar MSA-level resource and discovered this map at the CartoDB website: https://common-data.cartodb.com/tables/cb_2013_us_cbsa_5m/public/map
You can download several different formats, including GeoJSON and CSV. Here's a screenshot that shows the type and values of the data exported in CSV (since that was the original poster's requirement):
I hope this is helpful to others who come across this post!