Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.55 KB

README.md

File metadata and controls

46 lines (34 loc) · 1.55 KB

country_code_converter

Converts between different naming schemas for countries (ISO2, ISO3, car plate IDs, numerical, English, German, centroid).

country_code_converter.py exposes the main method get_cc. It looks for a country with value from_value (e.g. DEU) in the column specified by from_standard (e.g. iso3) and returns, for the column defined by to_standard (e.g. iso2) the corresponding value (e.g. DE), or the whole row, if to_standard is left unspecified.

Some columns are not actual country codes but related information, like full names or the centroid.

Command-line usage

python country_code_converter.py from_standard from_value [to_standard]

Available naming standards

name_english
alpha-2
alpha-3
numeric
name_german
car
centroid

Examples

Command-line

python country_code_converter.py name_english Italy car
> I

python country_code_converter.py name_english Italy

> {'name_english': 'Italy', 'car': 'I', 'numeric': '380', 'name_german': 'Italien', 'alpha-2': 'IT', 'alpha-3': 'ITA'}

Python

import country_code_converter
print country_code_converter.get_cc('name_english', 'Italy', 'car')

> I

License

MIT

Acknowledgements

This code wraps the contents of these pages:

TODO

  • render JavaScript code
  • persist index for faster response