| Crates.io | tabulate-rs |
| lib.rs | tabulate-rs |
| version | 0.1.0 |
| created_at | 2025-11-03 07:18:13.336258+00 |
| updated_at | 2025-11-03 07:18:13.336258+00 |
| description | Pretty-print tabular data. Port of python-tabulate to Rust. |
| homepage | |
| repository | https://github.com/krzysztofwos/tabulate-rs |
| max_upload_size | |
| id | 1914070 |
| size | 215,428 |
Rust port of the excellent python-tabulate library for pretty-printing tabular data.
TabulateOptions) that keeps configuration explicit while defaulting to the same semantics as python-tabulate.The current implementation matches python-tabulate 0.9.0 for:
simple_separated_format.disable_numparse and disable_numparse_columns).max_col_widths / max_header_col_widths, multiline cell handling, and whitespace preservation.SEPARATING_LINE.Snapshot fixtures (tests/fixtures/python_snapshots.json) are generated directly from python-tabulate 0.9.0 via scripts/generate_snapshots.py, and the python_snapshot_parity test ensures all formats and options stay in sync.
python scripts/generate_snapshots.py
use tabulate::{tabulate, TabulateOptions};
let data = vec![
vec!["Planet", "Radius (km)", "Mass (10^24 kg)"],
vec!["Mercury", "2440", "0.330"],
vec!["Venus", "6052", "4.87"],
];
let table = tabulate(
data,
TabulateOptions::new()
.headers(tabulate::Headers::FirstRow)
.table_format("grid"),
).unwrap();
println!("{table}");
cargo test to ensure unit tests and snapshot parity checks pass.python /tmp/generate_snapshots.py after adding new cases.TableFormat instances can be supplied via TabulateOptions::table_format_custom.Run the basic example:
cargo run --example basic
This prints:
+----------+---------------+---------------------+
| Planet | Radius (km) | Mass (10^24 kg) |
+==========+===============+=====================+
| Mercury | 2440 | 0.33 |
+----------+---------------+---------------------+
| Venus | 6052 | 4.87 |
+----------+---------------+---------------------+
| Earth | 6371 | 5.97 |
+----------+---------------+---------------------+
| Mars | 3390 | 0.642 |
+----------+---------------+---------------------+
MIT OR Apache-2.0