Last active
August 29, 2015 14:05
-
-
Save frantzmiccoli/23198ade1884418129b1 to your computer and use it in GitHub Desktop.
Cities filtered by size
This file contains 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
# Data source https://www.maxmind.com/en/worldcities | |
# Using https://github.com/Russell91/pythonpy | |
# We first extract the cities with more than 500000 inhabitants | |
# We then filter those in relevant countries | |
# We generate a string close to json from the output | |
cat worldcitiespop.txt|py -fx --i '(int(x.split(",")[4]) > 500000)'|\ | |
py -fx "x.split(',').pop(0) in ['us', 'it', 'es', 'pt', 'gb', 'ie', 'is', 'it', 'fr', 'ca', 'be', 'de', 'at', 'dk', 'se', 'fi', 'nl', 'no', 'ch', 'en','lu', 'pl']" |\ | |
py -x "json.dumps({'name': x.split(',')[2], 'latitude': float(x.split(',')[5]), 'longitude': float(x.split(',')[6])}, indent=4, sort_keys=True)+','" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment