A library to map country names to 2-letter 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
XKorXKX- KosovoEUorEUU- 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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1e59d5d30a2df05c7b49d4f483ebfa405d3dc11794b1b18e4e0533368471664
|
|
| MD5 |
d3f6bcb9206c1f149b17580eeb597cb9
|
|
| BLAKE2b-256 |
012e0853af279945e723cd8b217ed887a22e20eb6b125a28c2d3f6eee17be6cf
|
Provenance
The following attestation bundles were made for countrynames-1.16.10-py3-none-any.whl:
Publisher:
build.yml on opensanctions/countrynames
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
countrynames-1.16.10-py3-none-any.whl -
Subject digest:
b1e59d5d30a2df05c7b49d4f483ebfa405d3dc11794b1b18e4e0533368471664 - Sigstore transparency entry: 171880404
- Sigstore integration time:
-
Permalink:
opensanctions/countrynames@9743e10fd3b63742c70e9f0bd5fdc8e28f3b4bf7 -
Branch / Tag:
refs/tags/1.16.10 - Owner: https://github.com/opensanctions
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@9743e10fd3b63742c70e9f0bd5fdc8e28f3b4bf7 -
Trigger Event:
push
-
Statement type: