-
Notifications
You must be signed in to change notification settings - Fork 105
Conversion and IO
Tier: Intermediate
Commands covered: excel, to, json, jsonl, tojsonl, snappy, geoconvert, prompt, clipboard
Per-command flag reference lives in
/docs/help/. This page is the workflow layer — when to reach for each command and how they compose.
These commands bridge between CSV and other formats: Excel/ODS, JSON (array & JSONL), Parquet, SQLite, PostgreSQL, Snappy-compressed, GeoJSON/SHP, plus the OS clipboard and file picker dialogs.
The clipboard command is also covered in Selection & Inspection → clipboard. The geoconvert command is also covered in Geospatial → geoconvert. This page focuses on the I/O angle.
| If you want to… | Use | Notes |
|---|---|---|
| Convert Excel / ODS sheet → CSV | excel |
Pick sheet by name (case-insensitive) or index |
| CSV → Parquet / SQLite / Postgres / Excel / ODS / Data Package | to |
Parquet supports zstd / gzip / snappy / lz4raw |
| JSON array → CSV | json |
Use --jaq for nested / awkward JSON |
| JSONL → CSV | jsonl |
First line determines headers |
| CSV → JSONL with smart type inference | tojsonl |
Uses the stats cache for type inference |
| Streaming Snappy compress / decompress | snappy |
Most qsv commands auto-handle .sz
|
| CSV ↔ GeoJSON / SHP / SVG | geoconvert |
See Geospatial |
| OS file picker for input or output | prompt |
Pairs well with clipboard and lens
|
| Read/write the OS clipboard | clipboard |
See Selection & Inspection |
Export an Excel (.xls, .xlsx, .xlsm, .xlsb) or LibreOffice (.ods) sheet to CSV. The first non-empty row is treated as the header.
Example: export the first sheet of a workbook
qsv excel input.xlsx --output output.csvExample: export by sheet name (case-insensitive)
qsv excel --sheet 'Sheet 3' input.xlsx > sheet3.csvExample: export a sheet by negative index (last sheet)
qsv excel --sheet -1 input.xlsx > last_sheet.csvExample: export every sheet to its own CSV (one shell loop)
for i in $(qsv excel --metadata input.xlsx | qsv select sheet_name | qsv behead); do
qsv excel --sheet "$i" input.xlsx --output "${i}.csv"
doneThe MCP server and Claude Cowork plugin auto-convert Excel inputs via this command — see MCP Server.
See also: /docs/help/excel.md, to xlsx — the inverse (CSV → Excel), sniff.
CSV → other formats. Subcommands: parquet, xlsx, ods, sqlite, postgres, datapackage. Each can take multiple input CSVs (or a directory, or a .infile-list).
Example: convert NYC 311 to Parquet with zstd compression
qsv to parquet output_dir/ NYC_311_SR_2010-2020-sample-1M.csv
ls output_dir/
# NYC_311_SR_2010-2020-sample-1M.parquetThe parquet subcommand needs the polars feature. Default compression is zstd; override with --compression {zstd,gzip,snappy,lz4raw,uncompressed} and --compress-level N.
Example: load wcp.csv into a fresh PostgreSQL database
qsv to postgres 'postgresql://user:pass@host/db' wcp.csv
# Creates a table named "wcp"Example: load multiple related CSVs into a single SQLite database
qsv to sqlite analytics.db nyc311.csv weather.csv stations.csv
# Tables: nyc311, weather, stationsExample: Excel workbook with one sheet per CSV
qsv to xlsx report.xlsx q1.csv q2.csv q3.csv q4.csv
# Sheet names match file stemsExample: Frictionless Data Package — CSV + JSON metadata
qsv to datapackage datapackage.json wcp.csv country_continent.csvExample: include stats in the Data Package
qsv to datapackage --stats datapackage.json wcp.csv--stats runs qsv stats against each CSV and embeds the result in the Data Package descriptor.
See also: /docs/help/to.md, sqlp — read Parquet inline with read_parquet, schema --polars, Integrations: DuckDB.
JSON array → CSV. The input must be a flat array (or single object) — no nested arrays/objects without a --jaq flatten step.
Example: simple JSON array of fruit records
[
{"fruit":"apple","price":2.50,"calories":95},
{"fruit":"banana","price":1.00,"calories":105}
]qsv json fruits.json > fruits.csvExample: extract a nested array with jaq
# response.json has structure: { "data": { "items": [ {...}, {...} ] } }
qsv json --jaq '.data.items' response.json > items.csvSee also: /docs/help/json.md, jsonl, tojsonl, jaq syntax.
JSONL / NDJSON → CSV. The first JSON line determines the headers; subsequent lines must be consistent.
Example: GitHub events stream
qsv jsonl events.jsonl > events.csvExample: pipe an API response through jaq, then jsonl
curl -s 'https://api.github.com/events' \
| jaq -c '.[]' \
| qsv jsonl > events.csvSee also: /docs/help/jsonl.md, fetch — fetch writes JSONL by default.
CSV → JSONL with smart type inference. Runs stats first to determine the right JSON type (string, number, boolean, null) for each column. Reuses an existing stats cache.
Booleans are inferred when cardinality = 2 and values match t/f, 1/0, y/n, or <value>/null patterns.
Example: convert wcp.csv to JSONL with typed values
qsv tojsonl wcp.csv > wcp.jsonl
head -1 wcp.jsonl
# {"Country":"ad","City":"aixas","AccentCity":"Aixàs","Region":"06","Population":null,"Latitude":42.4833333,"Longitude":1.4666667}Note Population is null (not "") and the coordinates are numbers (not strings).
Example: pre-populate the stats cache, then convert (skips the type-inference scan)
qsv stats --cardinality --infer-dates --stats-jsonl wcp.csv
qsv tojsonl wcp.csv > wcp.jsonlSee also: /docs/help/tojsonl.md, jsonl, stats, Stats Cache & Caching.
Streaming Snappy compression / decompression. Four subcommands: compress, decompress, check (first 50 bytes), validate (whole file).
Most qsv commands already handle .sz files transparently — the snappy command is the explicit interface when you need:
- Multithreaded compression (5–6× faster than the auto-compression)
- Compression of non-CSV files (it's format-agnostic)
- Integrity check / validation of an existing
.sz
Example: compress a 15 GB NYC 311 export (multithreaded)
qsv snappy compress nyc311-full.csv > nyc311-full.csv.szExample: decompress to stdin for inline pipelines
qsv snappy decompress nyc311-full.csv.sz | qsv slice --len 100 | qsv tableExample: validate a .sz file is well-formed
qsv snappy validate suspicious.csv.sz && echo "OK" || echo "Corrupt"Example: implicit compression via output filename
qsv slice --len 1000 wcp.csv --output sample.csv.sz
# qsv compresses on write (single-threaded). Use `qsv snappy compress` for multithreaded.See also: /docs/help/snappy.md, Performance Tuning — when streaming compression pays off, Indexing, Compression & Diff.
Convert between CSV (or SVG) and various spatial formats — GeoJSON, SHP, KML, GPX, and more. Pairs nicely with geocode.
Example: GeoJSON → CSV
qsv geoconvert nta_boundaries.geojson geojson csv > nta.csvExample: CSV with WKT geometry → GeoJSON for QGIS
qsv geoconvert parcels.csv csv geojson --geometry geometry > parcels.geojsonExample: stdin input via prompt
qsv prompt -m 'Choose a GeoJSON file' -F geojson | qsv geoconvert - geojson csvSee also: /docs/help/geoconvert.md, Geospatial, geocode.
OS-native file dialog (input or output). Useful for ad-hoc analyses where you don't want to copy-paste paths.
Example: pick a file, summarize it, view results
qsv prompt | qsv stats | qsv lensExample: pick a spreadsheet → CSV → save dialog for the result
qsv prompt -m 'Select a spreadsheet' -F xlsx,xls,ods \
| qsv excel - \
| qsv prompt -m 'Save exported CSV to...' --fd-outputprompt is part of the UI feature group (✨🐻❄️🖥️) — not available in qsvlite / qsvdp / qsvmcp.
See also: /docs/help/prompt.md, clipboard, lens.
See Selection & Inspection → clipboard. TL;DR:
# Read from clipboard
qsv clipboard | qsv stats | qsv table
# Write to clipboard
qsv stats wcp.csv | qsv table | qsv clipboard --save- Command Reference (index)
- Selection & Inspection → clipboard
-
Geospatial —
geocodecompanion togeoconvert -
SQL & Polars —
sqlpreads Parquet / Arrow / JSONL inline -
Stats Cache & Caching —
tojsonlbenefits from the cache -
Integrations — using
to postgreswith DataPusher+, DuckDB workflows - Cookbook → Build a Data Pipeline
qsv — GitHub · Releases · Discussions · qsv pro · Try it online · Benchmarks · datHere · DeepWiki · Dual-licensed MIT / Unlicense
Edit this page: Contributing to the Wiki
Home · Why qsv? · Tier legend
- All Commands (index)
- Selection & Inspection
- Transform & Reshape
- Aggregation & Statistics
- Joins & Set Ops
- SQL & Polars
- Validation & Schema
- Conversion & I/O
- Geospatial
- HTTP & Web
- Scripting (Luau / Python)
- Indexing, Compression & Diff
- AI & Documentation