A library to map country names to ISO codes.
Project description
countrynames
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
orXKX
- KosovoEU
orEUU
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4eb5e93ee6b26737ae8246fbb6707f07504c9f814b4555e648e3009ff43d89ac |
|
MD5 | 4e97c97694a14382943510709e7d374e |
|
BLAKE2b-256 | 0f42b7d34fc2a13915f827638f8b0c0e37f11eba724fb5e11aa50240df651fe4 |
Provenance
The following attestation bundles were made for countrynames-1.16.4.tar.gz
:
Publisher:
build.yml
on opensanctions/countrynames
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
countrynames-1.16.4.tar.gz
- Subject digest:
4eb5e93ee6b26737ae8246fbb6707f07504c9f814b4555e648e3009ff43d89ac
- Sigstore transparency entry: 150006122
- Sigstore integration time:
- Predicate type:
File details
Details for the file countrynames-1.16.4-py3-none-any.whl
.
File metadata
- Download URL: countrynames-1.16.4-py3-none-any.whl
- Upload date:
- Size: 473.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9f27cd78aa2371aa4677521fb5e4374b25f4ceb710f90c9ae80541b3efcb619 |
|
MD5 | 9d9fc538a1fe1263846ed239a290cb07 |
|
BLAKE2b-256 | 2c274205dc4c8621a1a2d675e2db483bfae5d0e02938bc691ae0ab3d03b28d72 |
Provenance
The following attestation bundles were made for countrynames-1.16.4-py3-none-any.whl
:
Publisher:
build.yml
on opensanctions/countrynames
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
countrynames-1.16.4-py3-none-any.whl
- Subject digest:
d9f27cd78aa2371aa4677521fb5e4374b25f4ceb710f90c9ae80541b3efcb619
- Sigstore transparency entry: 150006125
- Sigstore integration time:
- Predicate type: