I want a .csv list, mysql database, or any other list of all U.S states and cities, including which cities are in which state. From this list I will generate a mysql database with the following fields:
states: - id (int, auto_increment, primary) - name (varchar 255) cities: - id (int, auto_increment, primary) - stateId (id of the state from states table to which this city belongs) - name (varchar 255)
Thanks in advance.
There are 4079 cities in the table. We use the built-in COUNT() function to find out the number of rows.
As of 2018, there are 19,495 incorporated cities, towns and villages in the United States.
The seven cities that passed the 50,000 population mark were Kyle, Texas (51,789); Burleson, Texas (51,618); Little Elm, Texas (51,042); Lincoln, California (50,649); Westfield, Indiana (50,630); Newark, Ohio (50,383); and Jeffersonville, Indiana (50,315).
You can get city/state information in tab-separated value format from GeoNames.org. The data is free, comprehensive and well structured. For US data, grab the US.txt
file at the free postal code data page. The readme.txt
file on that page describes the format.
I spent a while looking for such a file, and ended up doing one myself, you can get it from here:
https://github.com/grammakov/us_cities_and_states/tree/master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With