Skip to main content

Python library for converting Japanese region names and codes.

Project description

japancode

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

japancode-0.1.0.tar.gz (64.0 kB view hashes)

Uploaded Source

Built Distribution

japancode-0.1.0-py3-none-any.whl (67.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page