Created
May 22, 2012 09:50
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| 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