12345678910111213141516171819202122232425262728293031 |
- #!/usr/bin/env python3
- import sys
- import csv
- """
- Strip unneeded data from world cities database.
- https://simplemaps.com/data/world-cities
- """
- us_cities = []
- other_cities = []
- with open(sys.argv[1]) as infile:
- reader = csv.reader(infile, quotechar='"')
- next(reader) # skip header
- for row in reader:
- pt = (row[2], row[3])
- if row[4] == "United States":
- us_cities.append(pt)
- else:
- other_cities.append(pt)
- with open(sys.argv[2], "w") as outfile:
- for (lat, lng) in us_cities:
- outfile.write(f"{lat}, {lng}\n")
- with open(sys.argv[3], "w") as outfile:
- for (lat, lng) in other_cities:
- outfile.write(f"{lat}, {lng}\n")
|