Skip to main content

A library to map country names to 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 Distribution

countrynames-1.16.3.tar.gz (467.7 kB view details)

Uploaded Source

Built Distribution

countrynames-1.16.3-py3-none-any.whl (473.3 kB view details)

Uploaded Python 3

File details

Details for the file countrynames-1.16.3.tar.gz.

File metadata

  • Download URL: countrynames-1.16.3.tar.gz
  • Upload date:
  • Size: 467.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for countrynames-1.16.3.tar.gz
Algorithm Hash digest
SHA256 4f50be2c8416f381b7f74b0cf66abad8623306be460b9abcb36c8488d2adf3c1
MD5 541d07b888cfc1578c69d727142b6058
BLAKE2b-256 b4b08ce5c10bb75539f00f296584cab4f938fa6083626090364888322d3581fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for countrynames-1.16.3.tar.gz:

Publisher: build.yml on opensanctions/countrynames

Attestations:

File details

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

File metadata

File hashes

Hashes for countrynames-1.16.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa6af6cede7e8be6417857f35f940aad71ac00a1d97e4ad8d2214a8fbf081cc3
MD5 9c64334f22ac01039202ba57f2bb3421
BLAKE2b-256 54c098ebd1c956a32e428239651e9b87f4834ae5ce41bc972e6878a434b46b5b

See more details on using hashes here.

Provenance

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

Publisher: build.yml on opensanctions/countrynames

Attestations:

Supported by

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