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
- File is parsed with
serde_json - For JSONL, a first pass scans the first 100 lines to collect all keys (headers)
- Data is exported to temporary CSV with
csv_writer - 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:
| Format | Support |
|---|---|
.xlsx | Cell-by-cell streaming (low memory footprint) |
.xlsm | Cell-by-cell streaming |
.xlsb | Cell-by-cell streaming |
.xls | Full reading |
.ods | Full reading |
Operation
- List sheets: workbook is opened to list sheet names
- Export by sheet: each sheet is exported to temporary CSV
- Parallelism: sheets are processed in parallel (configurable rayon pool)
- 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_xlsxwriterlibrary 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:
- JSON is parsed with
serde_jsoninto aserde_json::Valuetree - The tree is analyzed to infer an Arrow schema with
StructandListtypes - Nested objects become Arrow
StructArraycolumns - Nested arrays become Arrow
ListArraycolumns json_arrow::convert_json_to_parquetdelegates the actual conversion toconversion::convert_json_nested_parallel(json_pipeline.rs), which reads the records in memory-adaptive blocks and converts each block to aRecordBatchon a rayon pool sized bymemory::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 accuracysrc/json_normalize.rs— Flattens nested JSON objects into dot-notation columns (e.g.address.city,address.zip), used by the CLI’s--flattenflag 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 -