pycountry
pycountry copied to clipboard
Support FIPS region codes
It would be great if support for FIPS region codes would be added so that also those codes would be recognized.
A random example:
PL-72
is actually PL-02
See https://en.wikipedia.org/wiki/List_of_FIPS_region_codes_(P%E2%80%93R)#PL:_Poland and https://en.wikipedia.org/wiki/ISO_3166-2:PL.
This should be doably by a simple mapping table.
This is the mapping I use for poland:
subdivision_mapping = {
# iso codes before 2018
"PL-DS": "PL-02",
"PL-KP": "PL-04",
"PL-LB": "PL-08",
"PL-LD": "PL-10",
"PL-LU": "PL-06",
"PL-MA": "PL-12",
"PL-MZ": "PL-14",
"PL-OP": "PL-16",
"PL-PD": "PL-20",
"PL-PK": "PL-18",
"PL-PM": "PL-22",
"PL-SK": "PL-26",
"PL-SL": "PL-24",
"PL-WN": "PL-28",
"PL-WP": "PL-30",
"PL-ZP": "PL-32",
# FIPS codes
"PL-72": "PL-02",
"PL-73": "PL-04",
"PL-76": "PL-08",
"PL-74": "PL-10",
"PL-75": "PL-06",
"PL-77": "PL-12",
"PL-78": "PL-14",
"PL-79": "PL-16",
"PL-81": "PL-20",
"PL-80": "PL-18",
"PL-82": "PL-22",
"PL-84": "PL-26",
"PL-83": "PL-24",
"PL-85": "PL-28",
"PL-86": "PL-30",
"PL-87": "PL-32"
}
I'd prefer to have this mapping inside the library for all regions (where it makes sense), so that
pycountry.subdivisions.get(code='PL-02')
and pycountry.subdivisions.get(code='PL-DS')
and pycountry.subdivisions.get(code='PL-72')
all return the same subdivision.
@tobiasschuerg The intention of this library is to be a python wrapper for ISO Codes and unfortunately FIPS falls outside of that. So this will definitely not make our development roadmap but if you'd like to submit a PR feel free :)