liveBook · Manning

CSV

As explained in DuckDB in Action

CSV is a delimited text format that represents tabular data as records with fields separated by a delimiter, commonly a comma.

CSV is a delimited text format for tabular records. DuckDB can load CSV files in bulk and in parallel, automatically mapping columns while inferring usable schema information. section 1.7.1

CSV works well as a practical interchange format: convert source data into CSV, compress it when useful, and query it directly with DuckDB without first creating persistent tables. It also provides a portable artifact for tools that do not support the original format. section 10.1.1 section 5.0

Convert XML data to compressed CSV

A command-line pipeline extracts selected XML fields, converts the result through JSON to CSV, writes a header, and compresses the output: `7z e -so stackoverflow.com-Comments.7z | xidel ... | (echo "Id,PostId,Score,Text,CreationDate,UserId" && jq -r '. | @csv') | gzip -9 > Comments.csv.gz`.

Listing 10.1 Converting the XML file via JSON to CSV
7z e -so stackoverflow.com-Comments.7z | \
xidel -se '//row/[(@Id|@PostId|@Score|@Text|@CreationDate|@UserId)]' - | \
(echo "Id,PostId,Score,Text,CreationDate,UserId" &&
jq -r '. | @csv') |
gzip -9 > Comments.csv.gz

Inspect the complete conversion command and its field-selection, header-generation, CSV-encoding, and compression stages. section 10.1.1

How DuckDB in Action covers it

How deep it goes
Explains parallel loading, automatic column mapping, schema inference, conversion, and compression, without detailing CSV parsing internals.
Examples
Demonstrates Stack Overflow exports converted from XML through JSON into compressed Comments.csv.gz files.
What it assumes
Assumes familiarity with DuckDB or command-line workflows while demonstrating CSV loading and conversion directly.
What you can do after
Apply it via DuckDB and command-line tools to convert, compress, query, and reuse tabular data.
How it connects
Connects CSV with DuckDB, SQL, Python, JSON, Parquet, XML, jq, xidel, and gzip.

Also explained in

Compare how 15 books explain CSV →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.