Skip to main content

A library to map country names to 2-letter ISO codes.

Project description

countrynames

build

This library helps with the mapping of country names to their respective two or three letter codes. The idea is to incorporate common names for countries, and even some limited misspellings, as they occur in source data.

There is also support for fuzzy matching, which uses a heuristic based on levenshtein distance.

Usage

import countrynames

assert 'DE' == countrynames.to_code('Germany')
assert 'DE' == countrynames.to_code('Bundesrepublik Deutschland')
assert 'DE' == countrynames.to_code('Bundesrepublik Deutschlan', fuzzy=True)
assert 'DE' == countrynames.to_code('DE')
assert 'DEU' == countrynames.to_code_3('Germany')

Non-standard country codes

  • XK or XKX - Kosovo
  • EU or EUU - European Union

For some dissolved countries (e.g. SUHH for Soviet Union) and sub-regions (e.g. GB-SCT for Scotland) special codes are defined and returned from both to_code and to_code_3.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

countrynames-1.16.10-py3-none-any.whl (474.9 kB view details)

Uploaded Python 3

File details

Details for the file countrynames-1.16.10-py3-none-any.whl.

File metadata

  • Download URL: countrynames-1.16.10-py3-none-any.whl
  • Upload date:
  • Size: 474.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for countrynames-1.16.10-py3-none-any.whl
Algorithm Hash digest
SHA256 b1e59d5d30a2df05c7b49d4f483ebfa405d3dc11794b1b18e4e0533368471664
MD5 d3f6bcb9206c1f149b17580eeb597cb9
BLAKE2b-256 012e0853af279945e723cd8b217ed887a22e20eb6b125a28c2d3f6eee17be6cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for countrynames-1.16.10-py3-none-any.whl:

Publisher: build.yml on opensanctions/countrynames

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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