Skip to content

Python library for converting Japanese region names and codes

License

Notifications You must be signed in to change notification settings

ozekik/japancode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

japancode

PyPI

japancode は、日本の都道府県・市区町村名や各種番号・記号(全国地方公共団体コードなど)を取得・変換するための Python ライブラリです。

現在の対応データ

(現在は都道府県レベルのみ対応しています)

インストール

pip install japancode

使い方

都道府県名のローマ字表記

from japancode import roman

print(roman("東京都"))  # => 'tokyo'
print(roman("東京都", capitalize=True))  # => 'Tokyo'

都道府県名のひらがな・カタカナ表記

from kana import kana

print(kana("東京都"))  # => 'とうきょうと'
print(kana("東京都", katakana=True))  # => 'トウキョウト'

全国地方公共団体コード

from japancode import lgcode

print(lgcode.tocode("東京都"))  # => '130001'
print(lgcode.reverse("130001"))  # => '東京都'

JIS X 0401 (都道府県コード)

from japancode import jiscode

print(jiscode.tocode("東京都"))  # => '13'
print(jiscode.reverse("13"))  # => '東京都'

ISO 3166-2

from japancode import isocode

print(isocode.tocode("東京都"))  # => 'JP-13'
print(isocode.reverse("JP-13")) # => '東京都'

開発・テスト

poetry install
poetry run pytest poetry run pytest ./japancode --doctest-modules --cov -vs

ロードマップ

  • 郵便番号
  • 市区町村レベルのコード
  • 地域メッシュ
  • ローマ字の長音表記対応
  • normalize
  • shorten
  • ドキュメントの整備

クレジット

  • code4fukui/localgovjp : list of local government in Japan (日本の地方自治体一覧オープンデータ) JSON/CSV (CC0)

ライセンス

MIT

About

Python library for converting Japanese region names and codes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages