file-convert
Convert data between CSV, JSON, and Markdown (YAML frontmatter + body).
Run CLIs from this skill's directory (the folder that contains this SKILL.md):
uv run scripts/<name>.py. Do not prefix skills/file-convert/.
Available Scripts
Unified CLI
uv run scripts/convert.py data.csv --from csv --to json
--from/--to accept csv, json, md. Supported directions:
csv→json, json→csv, md→json, json→md. Reads - for stdin.
CSV → JSON
uv run scripts/csv_to_json.py data.csv # infers int/float/bool/null
uv run scripts/csv_to_json.py data.csv --no-infer # keep strings
Streams rows via csv.DictReader; emits a JSON array. --delimiter to change separator.
JSON → CSV
uv run scripts/json_to_csv.py data.json # flattens nested keys (a.b.c)
uv run scripts/json_to_csv.py data.json --no-flatten # nested → JSON strings
Accepts a JSON array of objects (or a single object). Header is the union of keys.
Markdown → JSON
uv run scripts/md_to_json.py post.md
Splits YAML frontmatter (between --- fences) from the body. Emits
{"frontmatter": {...}, "body": "..."}.
JSON → Markdown
uv run scripts/json_to_md.py post.json
Reads {"frontmatter": {...}, "body": "..."} and writes a Markdown doc with a
YAML frontmatter block followed by the body.
Round-trip
csv → json → csv and json → md → json preserve data when flattening is off
or keys have no dots. unflatten() cannot rebuild JSON arrays (list indices
become dict keys).
Output & Exit Codes
- Converters write their result to stdout; diagnostics to stderr.
- Exit
0success,1error,2file not found.
Notes
- CSV↔JSON is standard-library only. Markdown conversion pulls in PyYAML via a PEP 723 inline dependency (correct YAML beats a hand-rolled parser).