Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Input Converters

Before entering the main pipeline (CSV → Parquet conversion), non-CSV formats are first converted to intermediate CSV.

JSON Converter

Module: src/json.rs

Supported Formats

  • Array of objects: [{"col": "val"}, {"col": "val2"}]
  • Single object: {"col": "val"}
  • JSONL / NDJSON: {"col": "val"}\n{"col": "val2"}

Operation

  1. File is parsed with serde_json
  2. For JSONL, a first pass scans the first 100 lines to collect all keys (headers)
  3. Data is exported to temporary CSV with csv_writer
  4. This temporary CSV is passed to the standard pipeline

Handling Missing Values

Missing keys in an object are written as empty strings (which will be treated as nulls by the pipeline).

Excel / LibreOffice Converter

Module: src/xlsx.rs

Library: calamine

Calamine allows reading spreadsheets without depending on Excel or LibreOffice:

FormatSupport
.xlsxCell-by-cell streaming (low memory footprint)
.xlsmCell-by-cell streaming
.xlsbCell-by-cell streaming
.xlsFull reading
.odsFull reading

Operation

  1. List sheets: workbook is opened to list sheet names
  2. Export by sheet: each sheet is exported to temporary CSV
  3. Parallelism: sheets are processed in parallel (configurable rayon pool)
  4. Name sanitization: sheet names are sanitized for filesystems

Output

Each sheet produces a Parquet file named <file>__<sheet>.parquet.

Reverse Converter: Parquet → CSV

Module: src/to_csv.rs

Uses the Arrow API to read the Parquet file and write CSV with csv_writer.

Reverse Converter: Parquet → JSONL

Module: src/to_jsonl.rs

  • One JSON object per line
  • Null fields are omitted
  • Uses Arrow formatters for type fidelity

Reverse Converter: Parquet → JSON

Module: src/to_json.rs

  • Produces a single JSON array containing one object per row
  • Null fields are omitted
  • Uses Arrow JSON writer for accurate type representation
  • Suitable for feeding into JSON-based tools and APIs

Reverse Converter: Parquet → XLSX

Module: src/to_xlsx.rs

  • Writes Parquet data into an Excel workbook (.xlsx)
  • Each Parquet file creates a single worksheet
  • Column headers use Parquet column names
  • Uses the rust_xlsxwriter library for robust XLSX generation

Native Arrow Path: JSON with Nested Structure

Modules: src/json_arrow.rs (schema inference + public entry point), src/conversion/json_pipeline.rs (parallel block engine)

When JSON data contains nested objects or arrays, the standard CSV-intermediate approach would flatten them into strings, losing structure. The native Arrow path handles this:

  1. JSON is parsed with serde_json into a serde_json::Value tree
  2. The tree is analyzed to infer an Arrow schema with Struct and List types
  3. Nested objects become Arrow StructArray columns
  4. Nested arrays become Arrow ListArray columns
  5. json_arrow::convert_json_to_parquet delegates the actual conversion to conversion::convert_json_nested_parallel (json_pipeline.rs), which reads the records in memory-adaptive blocks and converts each block to a RecordBatch on a rayon pool sized by memory::max_threads_for_memory — the same block/thread/ordering model as the CSV pipeline (see Parallel Processing)

This preserves the full JSON structure in the Parquet file, enabling downstream consumers (e.g. DuckDB, Spark, Pandas) to navigate nested fields natively.

Additional JSON modules:

  • src/json_leaf_infer.rs — Promotes leaf types (e.g. string → numeric) during JSON inference for better schema accuracy
  • src/json_normalize.rs — Flattens nested JSON objects into dot-notation columns (e.g. address.city, address.zip), used by the CLI’s --flatten flag as an alternative to the native Struct/List path

JSON diagnostics

src/diag.rs provides lightweight phase-timing/RSS instrumentation (diag::phase, diag::note) used throughout both the CSV and JSON pipelines; enable it with --diagnose or CONVERT_TO_PARQUET_DIAG.

Handling Compressed Files

Module: src/utils.rs

Extensions .gz and .zst are automatically detected. The file is decompressed to a temporary file (deleted at the end of execution thanks to NamedTempFile from tempfile).

For other formats (.bz2, .xz), the user must decompress via stdin:

bzcat data.csv.bz2 | convert_to_parquet -