This script downloads and extracts the country information and saves them in a json file
pip
.
Get your own copy by forking the repository
Clone or download your forked copy
git clone https://github.com/your-user-name/countries.git
Change directory to countries $ cd countries
Install the virtualenv (if not already installed)
python3 -m pip install --user virtualenv
python3 -m venv countries-env
source countries-env/bin/activate
pip install -r requirements.txt
$ python3 countries.py
That’s it! You now have a file called countries.json
. Open it in your favourite editor.
Sample data from countries.json
[{
"alpha2": "AD",
"alpha3": "AND",
"area": 468.0,
"capital": "Andorra la Vella",
"continent": "EU",
"id": 20,
"languages": [
"Catalan (ca)"
],
"name": "Andorra",
"neighbours": [
"ES",
"FR"
],
"phone": "376",
"population": 77006
},
{
"alpha2": "AE",
"alpha3": "ARE",
"area": 82880.0,
"capital": "Abu Dhabi",
"continent": "AS",
"id": 784,
"languages": [
"Arabic (ar-AE)",
"Persian (fa)",
"English (en)",
"Hindi (hi)",
"Urdu (ur)"
],
"name": "United Arab Emirates",
"neighbours": [
"SA",
"OM"
],
"phone": "971",
"population": 9630959
},
///
]
This has been tested on Windows 10 with cygwin installed and used as the terminal.
It works too in Ubuntu 18.04 and Mac OS
If this does not work for your system for any reason, please feel free to create an issue
All forms of contributions/criticism are welcome. It is only when i get critique that i will improve.
Please give it a star if you like it or create and issue out if you dislike it. You can also suggest any cool feature a feature with a pull request.
GNU General Public Licence See LICENSE and as specified in Geonames Terms and Conditions
©March 2019 - 2023 Bernard Che Longho