A Python package to access the most up-to-date and accurate info about countries and their associated subdivisons using the ISO3166-2 standard.
Project description
ISO3166-2
Custom-built Python wrapper for RestCountries (https://restcountries.com/) API which includes an abundance of information about all ISO3166 countries. But this package also includes information about all countrys' ISO3166-2 subdivision codes & names, which is absent from RestCountries. Available via a Python software package; a demo is available [colab][here].
Table of Contents
Introduction
iso3166-2 is a Custom-built Python wrapper for RestCountries (https://restcountries.com/) API which includes an abundance of information about all ISO3166 countries. But this package also includes information about all countrys' ISO3166-2 subdivision codes & names, which is absent from RestCountries. The International Organisation for Standards defines codes for the names of countries, dependent territories, special areas of geographical interest, and their principal subdivisions [1]. This repo focuses on the ISO3166-2 standard.
The ISO 3166-2 defines codes for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1. The official name of the standard is Codes for the representation of names of countries and their subdivisions – Part 2: Country subdivision code. It was first published in 1998 [2].
- pycountry used for foundation and build on top of it.
Latest Updates
- Script that calls the getISO3166 every so often to check for latest updates to restcountries.
- Call check_for_updates GCP func.
Installaion
Install the latest version of iso3166-2 via PyPi using pip:
pip3 install iso3166-2 --upgrade
Installation from source:
git clone -b master https://github.com/amckenna41/iso3166-2.git
cd iso3166_2
python3 setup.py install
Requirements
Usage
Create instance of Subdivisions class using a country's 2 letter alpha2 code:
import iso3166_2 as iso
canada_iso3166_2 = iso.subdivisions["CA"]
denmark_iso3166_2 = iso.subdivisions["DK"]
estonia_iso3166_2 = iso.subdivisions["EE"]
fiji_iso3166_2 = iso.subdivisions["FJ"]
Get list of subdivisions:
import iso3166_2 as iso
canada_iso3166_2["Subdivisions"]
canada_iso3166_2.subdivisions
Attributes
You can check the ATTRIBUTES.md file to get a description for each attribute/field in the json exports.
Issues or Contributing
Any issues, errors or bugs can be raised via the Issues tab in the repository. Due to the nature of the ISO consistently updating the ISO3166-2 codes/names every year the data in the JSON's may slightly lag behind these changes. My iso3166-updates repo was created to check for these updates periodically and implement them in the relevant repo's.
Contact
If you have any questions or comments, please contact amckenna41@qub.ac.uk or raise an issue on the [Issues][Issues] tab.
References
[1]: https://en.wikipedia.org/wiki/ISO_3166
[2]: https://en.wikipedia.org/wiki/ISO_3166-2
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for iso3166_2-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c7810bfc6ed66199cd64bcf836140771d7bcb012fd825cd3e698d702d5c6df7 |
|
MD5 | 35b64212278a117cd8ec19e1908cea68 |
|
BLAKE2b-256 | db54ad10dbb13e6bff2aba396c27b280eeb9b927fa40044f6743e5938be4fb3b |