-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special postal codes not handled #4
Comments
Glad you had no trouble with the library except for the missing code! This had me puzzled for a while, but it turns out this is a special postal code, known as a 大口事業所個別番号. So it seems it's only used for that one building. You can read more about the codes here: https://www.post.japanpost.jp/zipcode/dl/jigyosyo/readme.html If you use the general JP Post postal code search you'll see there's no result. https://www.post.japanpost.jp/cgi-zip/zipcode.php?zip=869-0198 These special postal codes are provided in a separate CSV file that I haven't added to posuto. I guess I should work on doing that... |
Ah, makes sense. I searched for the Sky Tree (〒131-8634) and it also didn't return anything ( |
Yes, it would be great if you could parse [0] https://www.post.japanpost.jp/zipcode/dl/jigyosyo/readme.html |
Did not work on this this month, I'll look at it again next month. |
This could use more testing, but it adds initial support for the office codes (大口事業所の個別番号). These data attached to these codes has little in common with normal postal codes, so it's saved using a different data structure.
OK, I think this is working in the latest release, v0.4.0. It turns out the data for these codes is different enough that converting it into the same format as normal postal codes doesn't make sense, so I just return them with a completely different structure. The JSON data is saved in a separate file. Some other things about these codes:
I have used the term "company" above, but technically the organizations that get codes can be government offices or other organizations. Also noting this here because it was hard to understand, but while the postal data uses five-digit JIS codes, the reference page uses six digit codes everywhere. Turns out the sixth digit is a check digit that's calculated in an odd way. |
Sounds really tricky to handle these codes.
👍
How did you figure it out? Had a look at that page (with my broken Japanese) and couldn't see an explanation of how to parse that code in the page or PDF files. 🤓 It's working for me now 👍 (venv) kinow@ranma:/tmp$ pip install -U posuto
Collecting posuto
Downloading https://files.pythonhosted.org/packages/af/97/8626d71e45e3f38bec91dd7558acd9b40246892aa66ce16531296a58e708/posuto-0.4.0.tar.gz (6.7MB)
|████████████████████████████████| 6.7MB 1.3MB/s
Installing collected packages: posuto
Running setup.py install for posuto ... done
Successfully installed posuto-0.4.0
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) kinow@ranma:/tmp$ python
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import posuto
>>> posuto.get('〒869-0198')
OfficeCode(jis='43368', kana='ナガスマチヤクバ', name='長洲町役場', prefecture='熊本県', city='玉名郡長洲町', neighborhood='大字長洲', banchi='2766', postal_code='8690198', old_code='86901', post_office='長洲', type='office', multiple=False, new=False, alternates=[])
>>> |
Well, first I checked what jisx0402 was. That led me to the reference page, which doesn't use the term jisx0402, and I saw it was all six digit codes. Then I checked the Wikipedia article and that mentioned the check digit, but when I calculated the check digit for the first entry in the offices file it didn't match up. Then I found the README on the reference page, which has some special rules about the check digit buried in it, and then it matched up and I was able to confirm the codes were the same. It is not well organized data. :/ Closing since this seems to work for now. |
Thanks for fixing and for the explanation. Kudos on the detective work!!! |
Hi,
Saw that the version 0.2.0 was out and that it had migrated from JSON to Sqlite. I've never used a Python library that does that (not that I am aware) nor packaged one. So decided to try and see if that worked, if that'd be slow, etc.
Installation was super smooth 👍 no issues found.
Then decided to test with a random address. Picked Tamana/Kumamoto (my distant family hometown), then googled a random address, and found this website: https://www.town.nagasu.lg.jp/default.html
The footer of the page contains: " 〒869-0198 熊本県玉名郡長洲町大字長洲2766番地 Tel:0968-78-3111 Fax:0968-78-1092"
I got the postal code, and tried the following code:
Searching the same postal code on Google.co.jp returns the right location on the map.
Not sure how to provide a pull request, but thought it could be useful to report this missing postal code?
Anyway, great library, and nice trick of including an sqlite DB, might come in handy some day.
Thanks!
Bruno
The text was updated successfully, but these errors were encountered: