Skip to content
Joel Natividad edited this page May 13, 2026 · 2 revisions

Conversion & I/O

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.

Quick decision table

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

excel

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.csv

Example: export by sheet name (case-insensitive)

qsv excel --sheet 'Sheet 3' input.xlsx > sheet3.csv

Example: export a sheet by negative index (last sheet)

qsv excel --sheet -1 input.xlsx > last_sheet.csv

Example: 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"
done

The 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.

to

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.parquet

The 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, stations

Example: Excel workbook with one sheet per CSV

qsv to xlsx report.xlsx q1.csv q2.csv q3.csv q4.csv
# Sheet names match file stems

Example: Frictionless Data Package — CSV + JSON metadata

qsv to datapackage datapackage.json wcp.csv country_continent.csv

Example: 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

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.csv

Example: extract a nested array with jaq

# response.json has structure: { "data": { "items": [ {...}, {...} ] } }
qsv json --jaq '.data.items' response.json > items.csv

See also: /docs/help/json.md, jsonl, tojsonl, jaq syntax.

jsonl

JSONL / NDJSON → CSV. The first JSON line determines the headers; subsequent lines must be consistent.

Example: GitHub events stream

qsv jsonl events.jsonl > events.csv

Example: pipe an API response through jaq, then jsonl

curl -s 'https://api.github.com/events' \
  | jaq -c '.[]' \
  | qsv jsonl > events.csv

See also: /docs/help/jsonl.md, fetchfetch writes JSONL by default.

tojsonl

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.jsonl

See also: /docs/help/tojsonl.md, jsonl, stats, Stats Cache & Caching.

snappy

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.sz

Example: decompress to stdin for inline pipelines

qsv snappy decompress nyc311-full.csv.sz | qsv slice --len 100 | qsv table

Example: 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.

geoconvert

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.csv

Example: CSV with WKT geometry → GeoJSON for QGIS

qsv geoconvert parcels.csv csv geojson --geometry geometry > parcels.geojson

Example: stdin input via prompt

qsv prompt -m 'Choose a GeoJSON file' -F geojson | qsv geoconvert - geojson csv

See also: /docs/help/geoconvert.md, Geospatial, geocode.

prompt

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 lens

Example: 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-output

prompt is part of the UI feature group (✨🐻‍❄️🖥️) — not available in qsvlite / qsvdp / qsvmcp.

See also: /docs/help/prompt.md, clipboard, lens.

clipboard (cross-reference)

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

See also

Clone this wiki locally