When writing a Proteus script to revise the subdivisions of a huge Party address pool,
I saw that there are countries that do not have a subdivision for all postal codes in the PostalCode module (for example Netherlands and Austria), and I found that France has two subdivisions per postal code, one of which is false for every postal code.
As far as I understand - please correct me if I’m wrong - the Country data is from Python pycountry, and the postal code data comes from geonames.org .
The problem that I found is that pycountry
- uses ISO 3166-2 code to identify a subdivision
whereas the export file from geonames.org
- in some files uses ISO codes to identify subdivisions (for example in DE.txt)
- but in other files uses FIPS region codes to identify subdivisions (for example in NL.txt and AT.txt)
Example: The Netherlands, subdivision “Flevoland”
ISO 3166-2 code (from pycountry): NL-FL
FIPS code (from geonames.org): NL-16
Example: Austria, subdivision “Kärnten”
ISO 3166-2 code (from pycountry): AT-2
FIPS code (from geonames.org): AT-02
As a result, no subdivision is available in Tryton for all postal codes in NL and AT.
To improve the situation I would
(1) analyze for which of the 96 available postal code files this problem exists
(2) give the trytond_import_postal_codes script a “translation table” from FIPS to ISO codes for the affected postal code files.
I would like to contribute and work on this topic, but I may not see the big picture at the moment.
If I am on the wrong track, or the effort will forseeable fail, please tell me.
Other thoughts on how to get the subdivisions right in Tryton?