Skip to content

Instantly share code, notes, and snippets.

@gearmonkey
Created May 22, 2012 09:50
Show Gist options
  • Save gearmonkey/2767939 to your computer and use it in GitHub Desktop.
Save gearmonkey/2767939 to your computer and use it in GitHub Desktop.
a quick filter to get rid of null entries in the world cities db
'''
filter out all the null population entries from the world cites database http://www.maxmind.com/app/worldcities
'''
import csv
with open('worldcitiespop.txt') as fh:
reader = csv.DictReader(fh)
cities_pop = [line for line in reader if line['Population']]
#print all the cities in the UK with a population above 200,000
print '\n'.join(['{0}: {1}'.format(entry['City'], entry['Population']) for entry in cities_pop if entry['Country']=='gb' and int(entry['Population']) > 200000])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment