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.

List, lookup with fuzzy search, and synonyms.

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.

Support

For feedback, feature requests, or support, please email support@commondata.net.

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.4.tar.gz (23.3 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.4-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: commondata_countries-2.1.4.tar.gz
  • Upload date:
  • Size: 23.3 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.4.tar.gz
Algorithm Hash digest
SHA256 54cd32b75597a1b1c38f3b4135f1818816763c94ec2edb2f4aed7d693acf867e
MD5 310d2798b2a902dc94655f26b868425e
BLAKE2b-256 167998c3b0e6a1a112fa9910e2342976ceef63a4e76a69c769b844b8ba7289e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for commondata_countries-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8d938771bb9f25bf563d6dc7cc7c790b6c171cba700f198da08dd7021e321d69
MD5 c3344290a671b7c3cf67adc90f51aa50
BLAKE2b-256 199f5790913042832d81ace9c2d43e94b1d93a2afdbe9677a377096e1bec41d6

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