Code as Manifesto: Reading Government Data Like an Engineer

IT Policy Proposals
Code as Manifesto: Reading Government Data Like an Engineer

どうも〜おかむーです! Hi — today I want to take a playful, slightly nerdy look at Japanese public datasets and what they tell us when you treat policy as code.

  • CSVs exist, but machine-readability and metadata vary wildly
  • Engineer-wise, APIs + schemas = measurable policy; many gov datasets stop short
  • Quick wins: charset normalization, schema, API layer, and open SLAs for data

結論

Public data availability is improving — many gov sites now publish CSVs (see NOTICE, MHLW, MOJ/Soumu datasets) — but publishing a CSV isn't the same as publishing policy as code. To make policy verifiable and reusable, governments need machine-readable schemas, stable APIs, versioning, and clear links between numeric targets and datasets.

Report

I looked at some real public CSV endpoints (from your search results):

  • NOTICE: https://notice.go.jp/docs/status_notice.csv
  • Ministry of the Environment (Ibaraki-related): https://www.env.go.jp/content/900398071.csv (463KB)
  • INPIT domestic migration list 2011: https://www.inpit.go.jp/content/100869372.csv
  • MHLW rescue facilities: https://www.mhlw.go.jp/content/001682075.csv
  • Soumu national CSV: https://www.soumu.go.jp/main_content/000323625.csv (104KB)

These are fantastic to see — CSVs beat PDFs for reuse — but look at the practical engineering issues that remain:

1) Encoding and parser pain

  • Many Japanese government CSVs historically use Shift_JIS or vendor-specific encodings. If you naively do pd.read_csv(url), you might get mojibake.
  • Engineer tip: always detect encoding and normalize to UTF-8 before processing.

Code snippet (Python/pandas):

import chardet, requests, io, 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)

print(df.head())

2) Missing machine-readable schema / metadata

  • CSVs often have no column descriptions, units, or data types. That makes validation, ETL testing, and linkage to policy targets hard.
  • Solution: publish a JSON Schema / CSVW / DCAT metadata file alongside each CSV.

3) No API or poor API ergonomics

  • A single static CSV is fine for snapshots, but an API helps consumers query, paginate, and integrate in real time. Also supports partial updates and access control if needed.
  • Engineer-wise, an OpenAPI + JSON endpoint that supports filtering (date ranges, locations) is an easy win.

4) Lack of time-series or versioning

  • For policy evaluation you need time-series or versioned records to compare actuals against targets. A single CSV snapshot obfuscates trends.
  • Use append-only datasets, or a dataset per date with consistent schema and a manifest.

5) Policy linkage gaps

  • Datasets rarely include explicit pointers to the policy they measure (e.g., policy_id, target_value, deadline). That makes automated compliance checks impossible.
  • Propose: include fields like policy_id, target_metric, target_value, target_date, and a link to the policy document.

Practical data pipeline pattern

  • Ingest: fetch CSVs, detect encoding, parse to canonical UTF-8
  • Validate: run schema validation (e.g., pandera or jsonschema)
  • Normalize: unify column names, types, geocoding (JIS codes), timestamps
  • Store: persist in a time-series DB / data lake with versioning (S3 + manifest)
  • Publish: expose an API (OpenAPI spec), and a dashboard for KPIs

Example JSON Schema snippet for a rescue-facility dataset:

{

"$id": "https://gov.example/rescue-facility.schema.json",

"type": "object",

"properties": {

"facility_id": {"type": "string"},

"name": {"type": "string"},

"capacity": {"type": "integer"},

"pref_code": {"type": "string"},

"last_updated": {"type": "string", "format": "date-time"}

},

"required": ["facility_id","name","capacity","pref_code"]

}

How to measure policy vs dataset (practical checks)

  • Does the policy state a numeric target? (e.g., reduce evacuation time to X minutes by 2026)
  • Can you locate a dataset column that maps to that metric?
  • Is there a time component so you can compute trends? If not, the policy is not programmatically verifiable.

These CSVs already give traction: they're structured and hostable on go.jp domains. Look at the file sizes — 463KB or 104KB — which suggests reasonable granularity. But without schema, API, or versioning, we still rely on manual work to validate outcomes.

Open-data and civic tech opportunities

  • Build an ingestion library that automatically detects gov CSV encoding, normalizes column names, and produces a standard JSON/Parquet export.
  • Offer a simple serverless API layer (e.g., Cloud Run + FastAPI) that wraps CSVs into queryable endpoints with caching and rate limits.
  • A public "policy as code" registry: dataset + schema + policy-id + SLA + owner. That makes automated audits possible.

Privacy & provenance

  • Some datasets (e.g., rescue facilities) are fine to publish openly. Others might contain personal data — practices must ensure anonymization and differential privacy where required.
  • Track provenance with dataset manifests (who published, when, hash of file) so consumers can trust and reproduce analyses.

まとめ

  • Seeing gov CSVs is already progress — CSV > PDF — but we need the next step: schema, API, versioning, and explicit links between datasets and policy targets.
  • Engineer-wise, these are solvable with proven tools: encoding detection, JSON Schema/CSVW, OpenAPI, and automated CI for data quality.
  • If the manifesto is "policy should be testable", then code + data + tests are the delivery pipeline.

おかむーから一言

I started companies to ship tech that actually moves the needle — public data should be the same. Let's make policies not just persuasive, but provable. If you want, I'll help sketch an API and schema for any of these CSVs — shotgun approach beats big bureaucratic meetings any day!