-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2317e2
commit e37077b
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,62 @@ | ||
# fifacodes | ||
|
||
FIFA country codes query and search. | ||
|
||
A mapping of FIFA country codes to country names. | ||
|
||
The default data is sourced from [Wikipedia](https://en.wikipedia.org/wiki/List_of_FIFA_country_codes). | ||
|
||
## Installation | ||
|
||
``` | ||
pip install fifacodes | ||
``` | ||
|
||
## Usage | ||
|
||
You can query like using dict: | ||
|
||
```pycon | ||
>>> from fifacodes import Counties | ||
>>> counties = Counties() | ||
>>> counties.get('ENG') | ||
Country(code='ENG', name='England') | ||
>>> len(counties) | ||
211 | ||
>>> list(counties.items())[0] | ||
('AFG', Country(code='AFG', name='Afghanistan')) | ||
``` | ||
|
||
Query by name: | ||
|
||
```pycon | ||
>>> counties['England'] | ||
Country(code='ENG', name='England') | ||
``` | ||
|
||
Search for a country by name or code, the search uses fuzzy string matching to find potential results. | ||
|
||
```pycon | ||
>>> counties.search('ARG') | ||
[Country(code='ARG', name='Argentina'), Country(code='AFG', name='Afghanistan'), Country(code='ALG', name='Algeria')] | ||
``` | ||
|
||
Results can be adjusted using parameters: | ||
|
||
```pycon | ||
>>> counties.search('Fran', limit=2, score_cutoff=70) | ||
[Country(code='FRA', name='France'), Country(code='IRN', name='Iran')] | ||
``` | ||
|
||
Search for a country by name or code and return the first result. | ||
|
||
```pycon | ||
>>> counties.search_one('Argent') | ||
Country(code='ARG', name='Argentina') | ||
``` | ||
|
||
## Data Update | ||
|
||
To update `default.csv` run `scrape.py`, If there are codes corresponding to other country names, add them to `custom.csv`. | ||
|
||
View source code for detailed usage. |