Recipe 10: CLI automation and batch processing
Current version: 3.1.0
Goal
Automate CSV/JSON conversion in scripts and CI.
Batch conversion
bash
# Convert all CSV files to JSON in a folder
npx jtcsv batch csv-to-json "data/*.csv" output/
# Convert all JSON files to CSV
npx jtcsv batch json-to-csv "data/*.json" output/Streaming CLI
bash
# Stream JSON to CSV
npx jtcsv stream json-to-csv input.json output.csv
# Stream CSV to JSON
npx jtcsv stream csv-to-json input.csv output.jsonScripted usage (Node.js)
js
const { execSync } = require('child_process');
execSync('npx jtcsv csv-to-json data.csv output.json --parse-numbers', {
stdio: 'inherit'
});Optional TUI
bash
npx jtcsv tuiNotes
- Use
--dry-runto validate commands without writing files. - See
docs/CLI.mdfor full options.
Navigation
- Previous: Database import/export with Prisma