Skip to main content

Work with ISO 3166-1 alpha2, alpha3 and numeric standard country data

Project description

commondata-countries

Work with ISO 3166-1 alpha2, alpha3 and numeric standard country data

Installation

pip install commondata-countries

Usage

Iterate over all countries:

from commondata_countries import CountryData

countries = CountryData()

for country in countries:
    print(country.name)

List all countries:

from commondata_countries import CountryData

countries = CountryData()

print(countries.all())

Lookup a country

from commondata_countries import CountryData

countries = CountryData()

# Lookup by name (case insensitive, fuzzy search)
country = countries["Untied States of America"]

# Lookup by ISO Alpha-2
country = countries["US"]

# Lookup by ISO Alpha-3
country = countries["USA"]

# Lookup by ISO Numeric
country = countries[840]

# Lookup by synonym
country = countries["United States"]

# Look up with fuzzy search
country = countries["United Stat"]

print(country)
> Country(name='United States of America', iso_alpha2='US', iso_alpha3='USA', iso_numeric=840)

Use CLI to lookup a country

python -m commondata-countries United States

Other Formats and Datasets

Download CSV, XLSX, JSON and YAML files from commondata.net/countries.

commondata.net maintains a collection of essential datasets in a variety of formats, including python bindings. Check out the full library here: commondata.net/library.

Contributing

Contributions are welcome! Please open an issue or submit a pull request here.

License

This project is licensed under GPLv3. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commondata_countries-2.1.3.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commondata_countries-2.1.3-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file commondata_countries-2.1.3.tar.gz.

File metadata

  • Download URL: commondata_countries-2.1.3.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for commondata_countries-2.1.3.tar.gz
Algorithm Hash digest
SHA256 8120ec0b991a97646e1ed6ea2d6635cccb564e89efa95b2494c04770f9f3dc8a
MD5 b5cbc8559017ea94ef64e27f7bb833bb
BLAKE2b-256 f48934aa92501d99c5e77fc1f47c43c4cdf55e0df1d3f4db95302af41b3cd232

See more details on using hashes here.

File details

Details for the file commondata_countries-2.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for commondata_countries-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9ef320da7ce164824debe328a57d7a74168584bf7c6f7c9c519196b218989e
MD5 04d1650e76fc157761a9ab6fccad49ea
BLAKE2b-256 0fc48310fdf71548e7e098035b43176b370e87b329fe1cbdf4080d523931cade

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page