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

convert-to-parquet

convert-to-parquet is a multi-format converter to Parquet written in Rust.

It converts CSV/TSV, JSON/JSONL/NDJSON and Excel spreadsheets (xlsx/xlsm/xlsb/xls/ods) to compressed Parquet files (ZSTD), with automatic schema inference and parallel processing.

It also supports reverse conversion: Parquet → CSV, Parquet → JSONL, Parquet → JSON (array of objects), and Parquet → XLSX (Excel workbook).

Key Features

  • Automatic type inference: Boolean, Int64, UInt64, Float64, Date32, Timestamp(ms), LargeUtf8
  • ZSTD compression (level 5) for optimized Parquet files
  • Parallelism: reading in blocks of 100,000 rows, parallel conversion (rayon), ordered writing (crossbeam)
  • Automatic detection of delimiter and header
  • Glob patterns: convert_to_parquet *.csv
  • stdin input: cat data.csv | convert_to_parquet -
  • Compressed files: .gz, .zst automatically decompressed
  • Detailed validation report for each conversion
  • Interactive mode: full-screen Parquet viewer (ratatui) with data preview and export to CSV / JSONL / JSON / XLSX
  • GUI application: graphical interface (egui/eframe) with schema editing, preview, batch conversion

Supported Formats

InputOutput
CSV, TSV, and other delimitersParquet (.parquet)
JSON, JSONL, NDJSONParquet
XLSX, XLSM, XLSB, XLS, ODSParquet (one sheet = one file)
ParquetCSV
ParquetJSONL
ParquetJSON
ParquetXLSX (Excel workbook)

Installation

Prerequisites

  • Rust (edition 2021)
  • An internet connection to download dependencies

Building from Source

# Clone the repository
git clone https://github.com/gildas-le-drogoff/convert_to_parquet.git
cd convert_to_parquet

# Build in release mode
cargo build --release

The binary is located in target/release/convert_to_parquet.

System Installation

# Install the CLI + GUI binaries, man page, .desktop launcher, and icon
make install

Installs convert_to_parquet and convert_to_parquet_gui to $(BINDIR), the man page to $(MANDIR), the icon to $(ICONDIR), and a .desktop launcher to $(DESKTOPDIR).

By default, installation is in /usr/local. To change the prefix:

make install PREFIX=~/.local

Verification

# Display version
./target/release/convert_to_parquet --version

# Display help
./target/release/convert_to_parquet --help

# Generate man page
./target/release/convert_to_parquet --man | man -l -

Getting Started

Simple Conversion

convert_to_parquet file.csv

Produces file.parquet in the same directory.

Custom Output

convert_to_parquet data.csv -o archive/data.parquet

Batch Processing (glob)

convert_to_parquet *.csv
convert_to_parquet datasets/**/*.csv

Each file produces its own .parquet file.

Compressed File

convert_to_parquet logs.csv.gz
convert_to_parquet logs.csv.zst

Decompression is automatic. For other formats (.bz2, .xz), use standard input:

bzcat logs.csv.bz2 | convert_to_parquet -

Reverse Conversion

# Parquet → CSV
convert_to_parquet --to-csv data.parquet -o data.csv

# Parquet → JSONL
convert_to_parquet --to-jsonl data.parquet -o data.jsonl

Inspecting a Parquet File

convert_to_parquet --view-schema data.parquet

Opening a Parquet file in a terminal launches a full-screen viewer (ratatui) for data preview and on-the-fly export to CSV, JSONL, JSON, or XLSX.

Subcommands

The tool automatically detects the operation to perform based on the input file type and provided flags.

Conversion → Parquet (default mode)

convert_to_parquet [OPTIONS] <INPUT...>

Automatic input format detection:

ExtensionFormat Processed
.csv, .tsvCSV/TSV (delimiter auto-detected)
.json, .jsonl, .ndjsonJSON / JSONL / NDJSON
.xlsx, .xlsm, .xlsb, .xls, .odsExcel / LibreOffice Spreadsheet
.parquetInteractive schema inspection
.gz, .zstAutomatic decompression then conversion

Reverse Conversion: Parquet → CSV

convert_to_parquet --to-csv <FILE.parquet> -o <OUTPUT.csv>

Reverse Conversion: Parquet → JSONL

convert_to_parquet --to-jsonl <FILE.parquet> -o <OUTPUT.jsonl>

Reverse Conversion: Parquet → JSON

convert_to_parquet --to-json <FILE.parquet> -o <OUTPUT.json>

Produces a JSON array of objects from the Parquet file. Null fields are omitted.

Reverse Conversion: Parquet → XLSX

convert_to_parquet --to-xlsx <FILE.parquet> -o <OUTPUT.xlsx>

Writes the Parquet data into an Excel workbook (XLSX). Each Parquet file becomes a single sheet in the workbook.

Preview Mode: JSON/JSONL

convert_to_parquet --preview <FILE.json>

Prints a tabular preview to stdout without writing a Parquet file. Nested JSON is shown flattened (see --flatten-separator, --flatten-max-level).

Schema Inspection

convert_to_parquet --view-schema <FILE.parquet>

Displays Parquet file metadata (compressed/decompressed size per column, null count).

Interactive Mode

When a Parquet file is passed without an export flag and the terminal is interactive, a full-screen viewer (ratatui) opens:

  1. Data preview with navigation through rows and columns
  2. On-the-fly export to CSV, JSONL, JSON, or XLSX

When the output is redirected (non-interactive), it falls back to printing the schema and statistics instead.

Generating the Man Page

convert_to_parquet --man > convert_to_parquet.1

General Options

OptionDescription
-o, --output <OUTPUT>Output file or directory. Treated as directory for multiple inputs
-d, --delimiter <DELIM>Force delimiter (; , \t |). Overrides automatic detection
--force-headerTreat the first line as column headers, skipping header auto-detection
--no-headerTreat the first line as data (no header row), skipping auto-detection
--overwriteOverwrite an existing output file instead of adding a timestamp suffix
--null-values <LIST>Comma-separated extra tokens treated as NULL in text columns (e.g. NA,ND)
--timezone <TZ>Timezone for timestamps, e.g. UTC, +02:00 (default: +00:00)
--flattenFlatten nested JSON into dot-separated columns instead of Arrow Struct/List
--flatten-separator <SEP>Column-name separator for --flatten (default: .)
--flatten-max-level <N>Max nesting depth for --flatten; deeper values are serialized as JSON strings
--previewPreview tabular data for a JSON/JSONL file (flattened nested view) without converting
--to-csvReverse conversion: Parquet → CSV
--to-jsonlReverse conversion: Parquet → JSONL
--to-jsonReverse conversion: Parquet → JSON (array of objects)
--to-xlsxReverse conversion: Parquet → XLSX (Excel workbook)
--full-schema-inferenceAnalyze entire file for type inference (instead of first 10,000 rows)
--force-utf8Force all columns to LargeUtf8 (disables inference, preserves raw data)
--view-schemaDisplay logical and physical schema of a Parquet file
--sheet-concurrency <N>Number of Excel sheets processed in parallel (default: ncpu/2)
--diagnoseLog per-phase timing and RSS to stderr (also via CONVERT_TO_PARQUET_DIAG)
--manGenerate man page in roff format

Details

--output

  • With a single input file: output file path
  • With multiple files (glob): treated as a directory
  • If path ends with /: always treated as a directory

--delimiter

Accepted values: , ; \t | or any character. Useful for files without standard extensions.

--force-utf8

Useful for heterogeneous data where type inference would produce unexpected mixing. No semantic loss, but larger files.

--force-header

Forces the first line to be treated as column headers, bypassing the header auto-detection heuristic. Useful when the heuristic misclassifies a header row as data (or vice versa).

--full-schema-inference

By default, only the first 10,000 rows are analyzed for schema inference. This option analyzes the entire file. Slower, but more accurate for files where types vary beyond the first rows.

--no-header

Forces the first line to be treated as data, bypassing the header auto-detection heuristic. Mutually exclusive with --force-header.

--null-values

Extra tokens (comma-separated, case-insensitive) treated as NULL in text columns, on top of the always-null null sentinel, e.g. --null-values NA,ND,NR.

--timezone

Sets the timezone applied when parsing textual timestamps (e.g. UTC, +02:00). Defaults to +00:00.

--flatten, --flatten-separator, --flatten-max-level

By default, nested JSON is preserved as Arrow Struct/List columns (see Input Converters). --flatten instead flattens nested objects into dot-separated columns (e.g. address.city), using --flatten-separator as the joiner and --flatten-max-level to cap nesting depth (deeper values are serialized as JSON strings). Only affects JSON input.

--preview

Prints a tabular preview of a JSON/JSONL file (flattened view for nested data) to stdout without producing a Parquet file. Requires exactly one JSON input.

--overwrite

By default, an existing output file is preserved and a timestamp suffix is appended to the new one. This flag overwrites the existing file instead.

--diagnose

Logs per-phase timing and memory (RSS) to stderr for each conversion phase. Can also be enabled via the CONVERT_TO_PARQUET_DIAG environment variable.

Supported Input Formats

CSV / TSV

Delimiters automatically detected: , ; \t |.

Detection is performed by counting occurrences of each potential delimiter on the first 20 lines. The most frequent and consistent delimiter is selected.

Header is detected via heuristics: comparing the profile of the first line (inferred types) with the rest of the data. If no header is found, columns are named col_0, col_1, etc.

JSON / JSONL / NDJSON

Supported formats:

  • Array of objects: [{...}, {...}]
  • Single object: {...}
  • One object per line (JSONL / NDJSON): {...}\n{...}\n

Flat JSON is first converted to intermediate CSV (keys become headers), then the standard pipeline converts it to Parquet.

When nested objects or arrays are detected, a native Arrow path is used instead, preserving the structure as Struct/List columns rather than flattening it to strings.

Excel / LibreOffice Spreadsheets

Supported formats:

ExtensionFormat
.xlsxExcel 2007+ (cell-by-cell streaming)
.xlsmExcel with macros
.xlsbBinary Excel (streaming)
.xlsExcel 97-2003
.odsOpenDocument Spreadsheet

Each sheet produces a distinct Parquet file: <file>__<sheet>.parquet.

Parallel sheet processing is configurable with --sheet-concurrency.

Compressed Files

The extensions .gz (gzip) and .zst (Zstandard) are automatically decompressed to a temporary file before conversion.

For unsupported formats (.bz2, .xz), use standard input:

bzcat data.csv.bz2 | convert_to_parquet -

Pipeline Overview

The conversion pipeline is the heart of the project. It transforms tabular data into a Parquet file efficiently and in parallel.

General Schema

Source File
     │
     ├─ Delimiter detection (first 20 lines)
     ├─ Header detection (heuristics)
     ├─ Schema inference (sample of 10,000 rows)
     │
     ├─ Reading in memory-adaptive blocks (10k-100k rows) ┐
     │                                                 │
     │   ┌─ Block 0 ─► Parallel analysis (rayon) ──┐   │
     │   ├─ Block 1 ─► Parallel analysis (rayon) ──┤   │
     │   ├─ Block 2 ─► Parallel analysis (rayon) ──┤   │
     │   └─ Block N ─► Parallel analysis (rayon) ──┘   │
     │                    │                            │
     │       crossbeam channel (ordered by index)      │
     │                    │                            │
     │         Ordered Parquet writing                 │
     │              (ZSTD level 5)                     │
     │                                                 │
     └─────────────────────────────────────────────────┘
     │
     └─ Validation report (stderr)

Detailed Steps

1. Input Format Resolution

The file is inspected to determine:

  • The delimiter (unless forced with -d)
  • Presence of a header
  • File type (CSV, JSON, XLSX, Parquet…)

2. Schema Inference

A sample of 10,000 rows is analyzed to determine the type of each column. See Type Inference.

3. Parallel Pipeline

The file is read in blocks sized by memory::adaptive_block_size (10,000-100,000 rows, based on available memory and column count — see Parallel Processing). Each block is sent through a crossbeam channel (block_sender) to a pool of rayon workers that:

  1. Convert each value according to the inferred type
  2. Build an Arrow RecordBatch
  3. Gather metrics (valid values, nulls, errors)

RecordBatch objects are returned via a second channel (batch_sender) with their original index.

4. Ordered Writing

The Parquet writing thread receives batches out of order (parallelism does not guarantee order). It reorders them using an internal BTreeMap before writing, ensuring that the row order from the source file is preserved.

5. Validation Report

Once conversion is complete, a detailed report is displayed on stderr:

========== VALIDATION REPORT ==========

CSV rows           1000000
Parquet rows       1000000
Parse errors             0

========== COLUMNS ==========

name                     type           null %      err %    valid %     conf
--------------------------------------------------------------------------------------
id                       Int64           0.00        0.00     100.00   100.00

Progress Ticker

A ticker thread runs in the background and updates the progress bar in real-time (MB/s) based on bytes read.

Diagnostics

With --diagnose (or CONVERT_TO_PARQUET_DIAG), each phase (csv_resolve_input_format, csv_resolve_schema, csv_run_pipeline, csv_count_parquet_lines, …) logs its duration and notes like csv_block_size, csv_analysis_threads, and memory_budget_bytes to stderr via src/diag.rs.

Type Inference

Type inference is a critical phase: it determines the Parquet schema that will be used for all data.

Method

Analysis is performed on a sample of 10,000 rows (except with --full-schema-inference). For each column, a TypeState accumulates observations:

#![allow(unused)]
fn main() {
struct TypeState {
    can_bool: bool,
    can_date: bool,
    can_timestamp: bool,
    can_int: bool,
    can_uint: bool,
    can_float: bool,
    min_value: i128,
    max_value: i128,
    // timestamp format counters
    ts_seconds: u64,
    ts_millis: u64,
    ts_micros: u64,
    ts_nanos: u64,
    ts_textual: u64,
    total_values: u64,
}
}

Each non-null value disables incompatible types. For example, a value containing a . disables can_bool, can_int, and can_uint.

Inferred Types

Parquet TypeDetection Conditions
Booleantrue/false, yes/no, y/n, on/off, t/f, 0/1
Int64Signed integers within i64 range
UInt64Positive integers exceeding i64 but within u64 range
Float64Numbers containing ., e or E
Date32Formats YYYY-MM-DD, DD/MM/YYYY, MM/DD/YYYY
Timestamp(ms)RFC3339, YYYY-MM-DD HH:MM:SS, variants with fractions and timezone
LargeUtf8Anything that doesn’t match above

Type Precedence

Types are tested in this order. The first type still possible at the end of sampling is selected:

  1. Boolean
  2. Int64 / UInt64
  3. Float64
  4. Date32
  5. Timestamp(ms)
  6. LargeUtf8 (fallback)

Timestamps have a confidence threshold of 80%: if less than 80% of non-null values in a column are valid timestamps, the type is downgraded to LargeUtf8.

Null Values

These values are treated as null regardless of column:

null, NULL, None, NaN, N/A, na, nd, nr, -, -- and empty strings.

Additional case-insensitive tokens can be added per-run with --null-values (e.g. --null-values NA,ND,NR); null is always treated as null.

Ambiguous Dates

For DD/MM/YYYY vs MM/DD/YYYY formats: both are tested, first successful parse wins. If both are valid, DD/MM/YYYY is retained.

--force-utf8 Mode

When this flag is enabled, inference is disabled and all columns are forced to LargeUtf8. Raw data is preserved without any conversion.

Full Inference (--full-schema-inference)

By default, only 10,000 rows are sampled. This flag analyzes the entire file, which is slower but more robust for files whose structure varies beyond the first rows.

Time Precision

The time unit is automatically detected:

  • Seconds: Unix timestamps < 10^10
  • Milliseconds: timestamps between 10^10 and 10^13
  • Microseconds: timestamps between 10^13 and 10^16
  • Nanoseconds: timestamps > 10^16

Textual values are parsed with chrono and converted to milliseconds.

Timestamps default to UTC (+00:00); override with --timezone (e.g. --timezone +02:00).

Parallel Processing

The project uses two complementary parallelism libraries: rayon and crossbeam.

Parallel Pipeline Architecture

                    ┌──────────────────────────┐
                    │   Sequential reading      │
                    │  (adaptive blocks, 10k-   │
                    │   100k rows)              │
                    └──────────┬────────────────┘
                               │
                    ┌──────────▼────────────┐
                    │  block_sender         │
                    │  (crossbeam, capacity │
                    │   8 blocks)           │
                    └──────────┬────────────┘
                               │
                ┌──────────────┼──────────────┐
                │              │              │
         ┌──────▼──────┐  ┌────▼─────┐ ┌──────▼───┐
         │ Worker 0    │  │ Worker 1 │ │ Worker N │
         │ (rayon)     │  │ (rayon)  │ │ (rayon)  │
         └──────┬──────┘  └────┬─────┘ └──────┬───┘
                │              │              │
                └──────────────┼──────────────┘
                               │
                    ┌──────────▼─────────────┐
                    │  batch_sender          │
                    │  (crossbeam, capacity  │
                    │   8 batches)           │
                    └──────────┬─────────────┘
                               │
                    ┌──────────▼────────────┐
                    │  Ordered writing      │
                    │  (BTreeMap + Parquet) │
                    └───────────────────────┘

Rayon: Data Parallelism

Rayon converts each CSV block to an Arrow RecordBatch in parallel via par_bridge():

#![allow(unused)]
fn main() {
block_receiver
    .into_iter()
    .par_bridge()
    .try_for_each(|block| {
        let result = analyze_block(&block.records, schema.clone(), force_utf8)?;
        batch_sender.send((block.index, result.batch, block.bytes_read))?;
        Ok(())
    })
}

Each block is processed independently on a rayon thread pool, allowing efficient use of all CPU cores.

Memory-Bounded Sizing (src/memory.rs)

Block size and worker thread count are no longer fixed: both are derived from available system memory.

  • memory::memory_budget() — 90% of currently available RAM (via /proc/meminfo on Linux, vm_stat/sysctl on macOS, GlobalMemoryStatusEx on Windows), minus a 64 MB safety margin
  • memory::adaptive_block_size(ncols) — targets 10% of the memory budget per block, clamped to 10,000-100,000 rows
  • memory::max_threads_for_memory(ncols, block_size) — caps the analysis thread pool so that threads × block_size × columns stays within budget, further capped by num_cpus
  • memory::max_concurrent_jobs() — used by the GUI to cap how many files convert concurrently (budget / 512 MB per job)

This keeps memory usage bounded on both small (e.g. containers, CI) and large machines, instead of a one-size-fits-all block size. The CSV pipeline, the native JSON pipeline (conversion/json_pipeline.rs), and the GUI worker all consult these functions. Values are logged via src/diag.rs when --diagnose is set.

Crossbeam: Bounded Channels

Crossbeam provides inter-thread communication channels with bounded capacity:

  • block_sender (capacity: 8 blocks) — from reader to workers
  • batch_sender (capacity: 8 batches) — from workers to writer

The advantage of bounded channels is backpressure: if workers are too slow, reading slows down; if the writer is too slow, workers slow down. The system naturally balances itself.

Strict Ordering

Blocks are numbered sequentially (block.index). Since parallelism does not preserve order, each RecordBatch is sent with its original index.

The writing thread maintains a BTreeMap that reorders batches:

#![allow(unused)]
fn main() {
let mut pending: BTreeMap<usize, (RecordBatch, u64)> = BTreeMap::new();
let mut next_index = 0;

// On each reception:
pending.insert(index, (batch, bytes));
// Write all ready batches in order
while let Some((batch, bytes)) = pending.remove(&next_index) {
    writer.write(&batch)?;
    next_index += 1;
}
}

This ensures that the row order from the source file is strictly preserved in the final Parquet file.

Progress Ticker

A dedicated thread (ticker) updates the progress bar in real-time:

  • Display in MB/s (megabytes per second)
  • 2-second smoothing window
  • Clean shutdown via AtomicBool
  • Cleaned up even on error (thanks to TickerStopGuard)

Excel Sheet Concurrency

For multi-sheet workbooks, each sheet is processed in a separate rayon pool, configurable with --sheet-concurrency. Default: ncpu / 2 threads.

Sheets are independent: each produces its own Parquet file.

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 -

GUI Application

The project includes a native desktop GUI built with egui/eframe, an immediate-mode GUI framework for Rust.

Launch

cargo run --bin convert_to_parquet_gui

The gui Cargo feature (enabling eframe, rfd, egui_extras) is a default feature, so a plain build/run enables it; on a build with --no-default-features, pass --features gui explicitly. The binary is declared in Cargo.toml as convert_to_parquet_gui, with its entry point at src/bin/gui_convert.rs; the GUI modules live under src/gui/.

Features

FeatureDescription
File drag-and-dropDrag input files onto the window, or use the file/folder picker (rfd)
Schema editingInspect and modify inferred column types/names before conversion
Column renaming (Parquet)For Parquet inputs, rename columns in place via parquet_rewrite::rename_parquet_columns
Data previewView a sample of the data before committing to conversion
JSON flatten optionsToggle --flatten / separator / max-level per file, same as the CLI
Batch conversionQueue multiple files and convert them in one operation, capped by memory-aware concurrency (memory::max_concurrent_jobs)
Overwrite guardsWarns when an output file already exists; lets you confirm
Export format selectionChoose output format(s): Parquet, CSV, JSONL, JSON, and/or XLSX (multiple at once)

Architecture

The GUI follows a model-view separation pattern:

┌────────────────────────────────────────────────────────────┐
│                convert_to_parquet_gui                      │
│  src/bin/gui_convert.rs (entry point → gui::run())         │
├────────────────────────────────────────────────────────────┤
│  src/gui/                                                  │
│  ├── mod.rs      ── Module wiring                          │
│  ├── app.rs      ── ConverterApp state, egui App impl      │
│  ├── model.rs    ── UI state types (FileOptions,           │
│  │                  OutputSelection, EditableField, ...)   │
│  ├── worker.rs   ── Background analysis/conversion         │
│  │                  threads (mpsc channel)                 │
│  ├── analysis.rs ── Input format detection                 │
│  ├── paths.rs    ── Output path resolution                 │
│  ├── theme.rs    ── egui theme setup                       │
│  └── view/                                                 │
│      ├── mod.rs     ── Menu bar, sidebar, outputs panel,   │
│      │                 overwrite modal                     │
│      ├── detail.rs  ── Per-file detail tabs (data/schema/  │
│      │                 options/validation/parquet stats)   │
│      └── preview.rs ── Data preview tab rendering          │
└────────────────────────────────────────────────────────────┘

Model-View Separation

  • Model (model.rs): data structures holding UI state — loaded files (FileEntry), per-file options (FileOptions, column edits), requested outputs (OutputSelection), job state (JobState).
  • View (view/): panels render the model and push UiActions back to app.rs, which mutates state and forwards work to worker.rs.

Background Worker Threads

Long-running analysis and conversions run on background worker threads (src/gui/worker.rs) to keep the UI responsive:

  1. Each queued file is analyzed (spawn_analysis) and, once started, converted (spawn_conversion) on its own std::thread::spawn thread.
  2. Concurrency is capped at memory::max_concurrent_jobs() (memory-budget-aware); queued jobs beyond the cap wait in JobState::Queued until a slot frees up.
  3. Workers send WorkerMsg (Analyzed, Progress, ProgressBytes, Done, Failed) back to the UI thread through an mpsc channel.
  4. The UI polls the channel each frame and updates per-file progress and results.

This design prevents the UI from freezing during large file conversions and bounds total memory use across concurrent jobs.

Usage Walkthrough

  1. Launch the application with cargo run --bin convert_to_parquet_gui
  2. Add files by dragging them onto the window or using the file picker
  3. Review schema for each file — adjust column types if needed
  4. Select output format from the drop-down (Parquet, CSV, JSONL, JSON, XLSX)
  5. Set output directory and confirm overwrite behaviour
  6. Click Convert — progress bars show per-file status
  7. View results in the results panel after completion

Key Source Files

FilePurpose
src/bin/gui_convert.rsEntry point for the convert_to_parquet_gui binary
src/gui/app.rsConverterApp state, egui App trait implementation, job scheduling
src/gui/model.rsUI state types: FileOptions, OutputSelection, EditableField, JobState, DetailTab
src/gui/worker.rsBackground analysis/conversion threads, WorkerMsg channel
src/gui/analysis.rsInput format detection for a dropped/picked file
src/gui/paths.rsOutput path resolution (per-file and per-sheet)
src/gui/theme.rsegui visual theme setup
src/gui/view/mod.rsMenu bar, sidebar, output-format panel, overwrite confirmation modal
src/gui/view/detail.rsPer-file detail tabs: data preview, schema editor, options, validation, Parquet stats
src/gui/view/preview.rsTabular data preview rendering

Contributing

Contributions are welcome! Here’s how to participate in the project.

Prerequisites

  • Rust (edition 2021)
  • Make (for build targets)

Workflow

# 1. Fork the repository

# 2. Clone your fork
git clone https://github.com/<your-username>/convert_to_parquet.git
cd convert_to_parquet

# 3. Create a branch
git checkout -b my-feature

# 4. Code!
# 5. Test
make test

# 6. Format
make fmt

# 7. Lint
make lint

# 8. Commit and push
git push origin my-feature

# 9. Open a Pull Request

Code Structure

src/
├── main.rs              # CLI entry point (clap, format dispatch)
├── bin/
│   └── gui_convert.rs   # Entry point for the convert_to_parquet_gui binary
├── lib.rs               # Module declarations
├── conversion/
│   ├── mod.rs           # Main pipeline (orchestration, ConvertOptions)
│   ├── csv_blocks.rs    # CSV reading in blocks
│   ├── parquet_writer.rs# Ordered Parquet writing
│   ├── pipeline.rs      # Parallel analysis workers
│   ├── json_pipeline.rs # Parallel block engine for native nested-JSON conversion
│   ├── ticker.rs        # MB/s progress bar
│   └── counting.rs      # Parquet row counting
├── analysis/
│   ├── mod.rs           # Block analysis
│   ├── builders.rs      # RecordBatch construction
│   ├── conversions.rs   # Value → Arrow type conversion
│   └── types.rs         # Metrics and error counters
├── schema.rs            # Type inference (sampling)
├── utils.rs             # Delimiter/header detection, dates, nulls
├── inspect.rs           # Parquet metadata display
├── json.rs              # JSON → intermediate CSV converter
├── json_arrow.rs        # Native Arrow path for nested JSON (entry point)
├── json_leaf_infer.rs   # Leaf type promotion in JSON inference
├── json_normalize.rs    # JSON flatten to dot-notation columns (--flatten)
├── xlsx.rs              # Excel → intermediate CSV converter
├── to_csv.rs            # Parquet → CSV converter
├── to_jsonl.rs          # Parquet → JSONL converter
├── to_json.rs           # Parquet → JSON (array of objects)
├── to_xlsx.rs           # Parquet → XLSX (Excel workbook)
├── export.rs            # Unified export dispatch
├── preview.rs           # Headless data preview (non-interactive)
├── tui.rs               # Interactive full-screen viewer (ratatui)
├── parquet_rewrite.rs   # Column renaming for Parquet files
├── data_generator.rs    # Test data generator binary
├── memory.rs            # System memory detection, adaptive block/thread sizing
├── diag.rs              # Per-phase timing/RSS diagnostics (--diagnose)
└── gui/                 # egui/eframe GUI application
    ├── mod.rs         # Module wiring, run()
    ├── app.rs         # ConverterApp state, egui App trait impl
    ├── model.rs       # File/schema/output UI state (FileOptions, OutputSelection, ...)
    ├── worker.rs      # Background analysis/conversion threads (mpsc channel)
    ├── analysis.rs    # Input format detection for the GUI
    ├── paths.rs       # Output path resolution
    ├── theme.rs       # egui theme setup
    └── view/
        ├── mod.rs     # Menu bar, sidebar, outputs panel, modals
        ├── detail.rs  # Per-file detail tabs (data/schema/options/validation/parquet stats)
        └── preview.rs # Data preview tab rendering

Conventions

Code

  • Formatting: cargo fmt (standard rustfmt)
  • Linting: cargo clippy -- -D warnings
  • No warnings: code must compile without warnings
  • Tests: any new feature must include tests

Commits

  • Commit messages in English
  • Prefixes: feat:, fix:, refactor:, docs:, test:, chore:
  • One line ≤ 72 characters for title

Documentation

Public modules must have a documentation comment (/// or //!). Public functions should document parameters and return value when behavior is not obvious.

API Reference

The complete Rust API documentation (generated by rustdoc) is available here:

Generate Documentation Locally

cargo doc --open

Main Modules

ModuleDescription
conversionConversion pipeline: orchestration, reading, writing
analysisBlock analysis, RecordBatch construction, metrics
schemaType inference via sampling
utilsDelimiter/header detection, date parsing
inspectParquet metadata inspection
jsonJSON → intermediate CSV conversion
xlsxSpreadsheet → intermediate CSV conversion
to_csvReverse Parquet → CSV conversion
to_jsonlReverse Parquet → JSONL conversion

Tests

Running Tests

# All tests
cargo test

# With output display
cargo test -- --nocapture

# Specific test
cargo test test_name

# Integration tests only
cargo test --test integration

Test Structure

The project has 20 integration test files in tests/, plus inline unit tests in several src/ modules.

Unit Tests (inline #[cfg(test)] mod tests in src/)

  • json.rs, json_arrow.rs, json_leaf_infer.rs, json_normalize.rs — JSON parsing, nested-type inference, flattening
  • xlsx.rs, to_xlsx.rs — spreadsheet reading and XLSX writing
  • memory.rs — /proc/meminfo parsing, adaptive block/thread sizing (Linux only)
  • diag.rs — phase-timing/RSS instrumentation
  • conversion/json_pipeline.rs — parallel nested-JSON block engine

Integration Tests (tests/)

  • schema_tests.rs, schema_threshold_tests.rs, schema_override_tests.rs — type inference, timestamp confidence threshold, forced column types
  • conversions_tests.rs — value → Arrow conversion
  • delimiter_tests.rs — delimiter auto-detection
  • analysis_tests.rs, error_analysis_tests.rs — block analysis, error counters
  • heuristic_robustness_tests.rs, noise_robustness_tests.rs — header/type heuristics under noisy data
  • strict_order_tests.rs — strict block ordering under parallel conversion
  • integration_pipeline_tests.rs — end-to-end CSV → Parquet pipeline
  • normalized_tests.rs — large scenario suite (also covers .gz/.zst auto-decompression)
  • utils_tests.rs — utilities (delimiter/header/date helpers)
  • xlsx_e2e.rs — Excel → Parquet round-trip
  • export_formats_tests.rs — JSON-array and multi-sheet-XLSX round-trips (forward and reverse)
  • inverse_and_inspect_tests.rs — Parquet → CSV/JSONL and schema/stats inspection
  • parquet_to_csv_robust_tests.rs — Parquet → CSV robustness
  • nested_json_tests.rs — native nested-JSON Arrow path and --flatten (separator, max-level, mixed depth)
  • parquet_rewrite_tests.rs — Parquet column renaming (GUI’s column-rename feature)
  • preview_tests.rs — headless data preview (--preview, viewer)

Fixture Generation

The src/data_generator.rs binary generates test data in CSV, TSV, JSON, and JSONL formats:

cargo run --bin data_generator

Produces datasets in datasets_tests/ with various noise strategies, typed columns, and edge-case scenarios.

Python Test

A Python script allows validating Parquet output:

python3 test_convert_to_parquet.py

Requirements: pyarrow (pip install pyarrow).

Makefile

make test    # cargo test
make check   # cargo check (quick verification)
make lint    # cargo clippy -- -D warnings
make fmt     # cargo fmt

Changelog

[0.4.1] - 2026-07-24

✨ New Features

GUI Application

  • Desktop GUI (cargo run --bin convert_to_parquet_gui): egui/eframe app with drag-and-drop, schema/column editing, multi-format output selection (Parquet/CSV/JSONL/JSON/XLSX), Parquet column renaming, and memory-bounded concurrent batch conversion. See GUI Application.

CLI Options

  • --no-header, --overwrite, --diagnose
  • --null-values <LIST>: extra NULL sentinels
  • --timezone <TZ>: timestamp timezone override
  • --flatten, --flatten-separator, --flatten-max-level: flatten nested JSON to dot-notation columns instead of Arrow Struct/List
  • --preview: headless tabular preview of a JSON/JSONL file

🔧 Technical Improvements

  • Memory-adaptive pipeline (src/memory.rs): block size (10k-100k rows) and worker thread count now scale with available RAM instead of fixed constants, shared by the CSV pipeline, the native nested-JSON pipeline, and the GUI’s job concurrency
  • Native nested-JSON pipeline (src/conversion/json_pipeline.rs): parallel block engine backing json_arrow::convert_json_to_parquet, mirroring the CSV pipeline’s ordering/threading model
  • Diagnostics (src/diag.rs, --diagnose / CONVERT_TO_PARQUET_DIAG): per-phase timing and memory notes on stderr
  • Parquet column renaming (src/parquet_rewrite.rs): rewrite column names in an existing Parquet file
  • src/csv_generator.rs replaced by src/data_generator.rs (CSV, TSV, JSON, JSONL fixtures)

🧪 Tests

  • tests/parquet_rewrite_tests.rs, tests/preview_tests.rs, tests/schema_override_tests.rs
  • tests/nested_json_tests.rs extended with --flatten coverage (separator, max-level, mixed depth)

[0.4.0] - 2026-06-19

✨ New Features

Interactive Viewer (TUI)

  • Parquet Interactive Mode: opening a .parquet file in a terminal launches a full-screen viewer (ratatui)
    • Data preview, navigation, and on-the-fly export to CSV / JSONL / JSON / XLSX
    • Automatic fallback to schema + statistics display when output is redirected

New Export Formats (Parquet → …)

  • Parquet → JSON: export as a JSON array (src/to_json.rs)
  • Parquet → XLSX: export as an Excel workbook (src/to_xlsx.rs)
  • Unified export module src/export.rs

Nested JSON Objects

  • Nested JSON: support for nested objects/arrays via Arrow (src/json_arrow.rs)

🔧 Technical Improvements

  • Exposed a reusable library (src/lib.rs) consumed by integration tests
  • rust_xlsxwriter promoted to a runtime dependency (XLSX export), added ratatui
  • Regenerated man page (convert_to_parquet.1): up-to-date version and synopsis

🧪 Tests

  • tests/export_formats_tests.rs: CSV/JSONL/JSON/XLSX export
  • tests/nested_json_tests.rs: nested JSON objects
  • tests/noise_robustness_tests.rs: robustness against noisy data

[0.3.0] - 2026-06-14

✨ New Features

Support for New Input Formats

  • JSON / JSONL: automatic conversion of .json, .jsonl, .ndjson files to Parquet
    • Support for arrays of objects, single object, or one object per line
    • Header extraction via two-pass scan for JSONL
  • Excel Files: support for .xlsx, .xlsm, .xlsb, .xls, .ods
    • Cell-by-cell streaming for xlsx/xlsb (low memory footprint)
    • Parallel sheet processing (configurable with --sheet-concurrency)
    • One sheet = one Parquet file: <filename>__<sheetname>.parquet
  • Compressed Files: support for .gz and .zst input (automatic decompression to temporary file)

Reverse Conversion (Parquet → Other Formats)

  • Parquet → CSV: new --to-csv option
  • Parquet → JSONL: new --to-jsonl option
    • One JSON object per line, null fields omitted
    • Using Arrow formatters for type fidelity

Enhanced CLI Interface

  • Glob Expansion: convert_to_parquet *.csv processes all matching files
  • Forced Delimiter: --delimiter (supports , ; \t |)
  • Flexible Output: -o can be a file or folder (automatic detection)
  • Parquet Interactive Mode: if interactive terminal, displays schema + statistics then offers CSV/JSONL export
  • Man Page Generation: --man unchanged

Parquet File Inspection

  • New --view-schema command (already existing, but improved)
  • Display column statistics: compressed/decompressed sizes, null count

🔧 Technical Improvements

Temporal Precision

  • Timestamp: preservation of sub-millisecond precision (microseconds, nanoseconds)
  • Direct conversion to target unit without loss (Second, Millisecond, Microsecond, Nanosecond)
  • Smarter unit detection (textual or numeric, with plausibility window)

CSV Reading Reliability

  • Multi-line Field Handling: quotes are correctly interpreted
  • Blocks sent with their byte position (reliable progress bar)
  • Block reordering in Parquet writing (even in parallel)

Metrics and Progress

  • Progress bar based on MB/s (replaces “rows/s”)
  • Ticker thread cleanup (prevents zombie processes)
  • Conversion metrics: valid values, explicit nulls, conversion errors, error samples

Schema Inference

  • Confidence threshold for timestamps: 80% (configurable)
  • Improved type detection (bool, date, timestamp, int, uint, float)
  • Sampling limited to 10,000 rows (except --full-schema-inference)

📁 Structural Changes

New Modules

  • src/json.rs: JSON → temporary CSV conversion
  • src/xlsx.rs: Excel spreadsheet reading
  • src/inspect.rs: Parquet statistics
  • src/to_csv.rs: Parquet → CSV
  • src/to_jsonl.rs: Parquet → JSONL

Refactored Modules

  • src/analysis/: cleaner splitting, generic builders
  • src/conversion/: parallel pipeline, MB/s ticker, block handling with position
  • src/schema.rs: types renamed to English, inference logic clarified
  • src/utils.rs: compression functions, advanced temporal parsing

🗑️ Deletions

  • Empty module automatic_rejection_tests.rs
  • Unused variables in ErrorCounters
  • Dependency on CSV reconstruction in analyze_block()

🧪 Tests

  • New integration tests for JSON, XLSX and multi-line CSV fields
  • Timestamp precision tests (microseconds, nanoseconds)
  • Verification of strict row ordering in parallel pipeline

🌐 Internationalization

  • Codebase fully in English: variable names, error messages, logs, comments, and end-user messages