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.4.tar.gz (467.8 kB view details)

Uploaded Source

Built Distribution

countrynames-1.16.4-py3-none-any.whl (473.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: countrynames-1.16.4.tar.gz
  • Upload date:
  • Size: 467.8 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.4.tar.gz
Algorithm Hash digest
SHA256 4eb5e93ee6b26737ae8246fbb6707f07504c9f814b4555e648e3009ff43d89ac
MD5 4e97c97694a14382943510709e7d374e
BLAKE2b-256 0f42b7d34fc2a13915f827638f8b0c0e37f11eba724fb5e11aa50240df651fe4

See more details on using hashes here.

Provenance

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

Publisher: build.yml on opensanctions/countrynames

Attestations:

File details

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

File metadata

File hashes

Hashes for countrynames-1.16.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d9f27cd78aa2371aa4677521fb5e4374b25f4ceb710f90c9ae80541b3efcb619
MD5 9d9fc538a1fe1263846ed239a290cb07
BLAKE2b-256 2c274205dc4c8621a1a2d675e2db483bfae5d0e02938bc691ae0ab3d03b28d72

See more details on using hashes here.

Provenance

The following attestation bundles were made for countrynames-1.16.4-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