Code Speaks: Reading Japan’s Public Data as Infrastructure

どうも〜おかむーです!今日はちょっとエンジニアっぽい話をしますよ〜
- Government publishes a lot of CSVs, but machine-readability and schema quality vary widely
- Key issues: encoding, missing metadata, inconsistent codes; fixable with API+schema work
- Practical recipe: fetch CSVs, normalize codes (use soumu mapping), validate, expose as versioned JSON/CSV
結論
Public data exists in many places (notice.go.jp, env.go.jp, mhlw.go.jp, soumu.go.jp...), but the current landscape is a mixture of usable CSVs and frustrating edge cases. As an engineer, I think the priority is: canonical code tables + consistent encodings + per-file schema (CSVW/JSON-LD) + a lightweight API gateway. 要するに、データを“プログラムが使える形”に揃えれば、政策評価も自動化できるってことです。
Report: what I looked at and what it implies
What’s available (examples)
- NOTICE: https://notice.go.jp/docs/status_notice.csv — a direct CSV, nice!
- env.go.jp CSV (prefecture dataset) — CSV is good but need schema
- inpit.go.jp domestic migration CSV — legacy tables often lack metadata
- mhlw.go.jp CSVs — frequent encoding quirks and inconsistent column names
- soumu.go.jp code mapping: https://www.soumu.go.jp/main_content/000420038.csv — critical for joins
Check this out: many agencies already publish CSVs, which is excellent. But CSV alone isn’t enough if encoding, column semantics, and stable identifiers are missing.
Technical problems I repeatedly see
- Encoding ambiguity (Shift_JIS vs UTF-8 vs BOM). Code readers choke unless you detect encoding.
- Missing machine-readable metadata (what do columns mean? units? fiscal year?). Without that you can’t compute KPI gaps reliably.
- Inconsistent identifier types: sometimes numeric codes are zero-padded, sometimes not — joins fail.
- No centralized API or consistent versioning: pulling many CSVs for reproducible analysis is painful.
Practical engineering checks (how I’d validate)
- Verify encoding and normalize to UTF-8.
- Coerce identifier columns to string and normalize padding.
- Use soumu code mapping as canonical join key for administrative areas.
- Validate time-series continuity and KPI fields.
Example Python snippet (pseudocode you can run):
import requests, chardet, pandas as pd
r = requests.get('https://notice.go.jp/docs/status_notice.csv')
enc = chardet.detect(r.content)['encoding']
df = pd.read_csv(io.BytesIO(r.content), encoding=enc, dtype=str)
normalize codes
df['pref_code'] = df['pref_code'].str.zfill(2)
join with Soumu mapping
codes = pd.read_csv('https://www.soumu.go.jp/main_content/000420038.csv', dtype=str)
merged = df.merge(codes, left_on='pref_code', right_on='code', how='left')
要するに、encoding detection + dtype=str + canonical code joinがセットです。
Policy evaluation: KPI vs actuals
Most policy documents provide targets, but CSVs rarely include clearly labeled target vs actual fields or timestamps in ISO format. That makes computing the gap a multi-step ETL job: extract (CSV), normalize (codes/dates/units), transform (compute rate/percentage), load (analytics DB). If agencies published a small machine-readable KPI manifest per program (JSON with target, baseline, unit, time_horizon), automated monitoring becomes trivial.
Design proposals (engineering-first)
- Publish a per-file CSVW/JSON-LD schema alongside each CSV (column types, units, licenses). That’s low-effort and huge ROI.
- Canonical code service: a single API endpoint that returns administrative code mappings (versioned). Use soumu as source of truth.
- Minimal REST API: /datasets/{id}/{version}/rows.json with pagination + CSV download, plus ETag and timestamps.
- Adopt UTF-8 with BOM-free files, or always indicate encoding in HTTP headers.
- Offer a small SDK (Python) that wraps fetching, encoding normalization, and joins to the canonical codes.
Quick architecture sketch
- Ingest layer: periodic fetch of agency CSVs (with encoding detection)
- Normalizer: apply CSVW schemas, coerce columns, pad codes, validate types
- Storage: columnar store (Parquet) + analytics DB for KPI queries
- API: versioned, supports JSON/CSV, has dataset-level metadata (DCAT, license)
まとめ
現状、政府のCSV公開はあるけど“エンジニアがすぐ使える状態”には差がある。解決は単純で、スキーマ宣言(CSVW/JSON-LD)、コードの正規化(soumuのマッピング活用)、エンコーディング統一、そして小さいAPIゲートウェイを作ること。これだけで政策のモニタリングや再現可能な分析が一気に捗りますよね。
おかむーから一言
テクノロジーは細かいところを揃えるだけで社会を変えます。投資は小さく、リターンは大きい。やりましょう!
Sources
- https://notice.go.jp/docs/status_notice.csv
- https://www.env.go.jp/content/900398071.csv
- https://www.inpit.go.jp/content/100869372.csv
- https://www.mhlw.go.jp/content/001429362.csv
- https://www.soumu.go.jp/main_content/000420038.csv
- https://www.zhihu.com/question/290714454
- https://www.soumu.go.jp/menu_news/s-news/01toukatsu01_02000186.html
- https://www.zhihu.com/question/6430289390
- https://www.cas.go.jp/jp/seisaku/digital_gyozaikaikaku/data8/data8_siryou1.pdf
- https://www.zhihu.com/question/38923279
- https://www.digital.go.jp/
- https://www.chisou.go.jp/sousei/pdf/r5_guideline-checkaction.pdf
- https://ja.wikipedia.org/wiki/%E3%83%87%E3%82%B8%E3%82%BF%E3%83%AB
- https://www.pref.yamaguchi.lg.jp/uploaded/attachment/160746.pdf
- https://quants.co.jp/articles/306/
Share
Related Reports

Code-driven Manifesto: Auditing Local Gov Data and Systems (Kagawa case study)
Local gov systems run but hide data behind UIs; expose CSV/JSON, APIs, and common schemas to unlock value.

Code-driven Check: Japan’s Open Data and the Machine-Readable Gap
Digital Japan has dashboards and rules, but PDFs and messy formats still block automated policy verification; mandate CSV/JSON, APIs, and dataset linting.

Code Speaks: Testing Japan's Gov Data and Dashboards
Japan has great dashboards but inconsistent machine-readability. This report inspects e-Stat, Japan Dashboard, Kantei PDFs, and proposes API-first fixes and practical code examples.