Created
October 14, 2017 19:48
-
-
Save sergiolucero/c1173589a9e165f96158558d31213826 to your computer and use it in GitHub Desktop.
pull population data from Wikipedia
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
| import wikipedia | |
| CITIES=['Paris','Barcelona','Tokyo', 'New York City','Amsterdam','Copenhaguen','San Francisco'] | |
| AMBIGUOUS_CITIES = ['Santiago'] | |
| for city in CITIES: | |
| citywiki = wikipedia.page(city) | |
| cwsum = citywiki.summary | |
| poploc = cwsum.index('population') # first and only? use re! | |
| print(city, cwsum[poploc:poploc+30]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment