This probably seems like a duplicate, since there are identical questions out there.
Unfortunately all of the answers to all of these questions are missing one detail: the states.
Where can I get a list of countries, states and cities?
For example, I want this:
| Sydney | New South Wales | Australia |
or
| Miami | Florida | United States |
I don't want something like this, which excludes the state:
| Miami | United States |
Is there any place where I can get this kind of data?
I've already tried the following data sources:
- http://www.maxmind.com/app/csv
- http://www.geodatasource.com/world-cities-database/free
- http://developer.yahoo.com/geo/geoplanet/data/
But all of them exclude the states.
Geonames has a lot of data on places (including towns and cities) but it seems to be contributed and perhaps not complete.
Perhaps also try SQL Dumpster, I've used this website a lot for these kinds of databases, cities, provinces, etc. Unfortunately it's not free but only appears to be a one-time fee.
geonames is nice. an export tool based on geonames:
https://github.com/yosoyadri/GeoNames-XML-Builder
https://github.com/yosoyadri/GeoNames-XML-Builder/blob/master/continents-countries-statesprovinces.xml
there's also the excellent pycountry module:
http://pypi.python.org/pypi/pycountry
The UN maintains a list of countries and "states" / regions for economic trade. That DB is available here: http://www.unece.org/cefact/locode/welcome.html
Check this out! It was built no longer ago in 2014.
Get a list of country/state/city in a hierarchy using geonames webservice
geonames.org has an api and a data dump of worldwide geographical places.
This may be a sideways answer, but if you download Virtuemart (A Joomla component), it has a countries table and all the related states all set up for you included in the installation SQL. They're called
jos_virtuemart_countries
andjos_virtuemart_states
. It also includes the 2 and 3 character country codes. I'd attach it to my answer, but don't see a way of doing it.