| Crates.io | dsq-formats |
| lib.rs | dsq-formats |
| version | 0.1.0 |
| created_at | 2025-12-15 17:48:24.339039+00 |
| updated_at | 2025-12-15 17:48:24.339039+00 |
| description | File format support for dsq - handles reading and writing various data formats |
| homepage | |
| repository | https://github.com/durableprogramming/dsq |
| max_upload_size | |
| id | 1986451 |
| size | 370,251 |
File format support for DSQ - handles reading and writing various data formats.
dsq-formats provides comprehensive support for reading and writing multiple structured data formats. It serves as the I/O layer for DSQ, converting between different file formats and DSQ's internal data representations.
Add this to your Cargo.toml:
[dependencies]
dsq-formats = "0.1"
Enable specific formats:
[dependencies]
dsq-formats = { version = "0.1", features = ["csv", "json", "parquet"] }
use dsq_formats::csv::read_csv_file;
fn main() {
let df = read_csv_file("data.csv")
.expect("Failed to read CSV");
println!("Loaded {} rows", df.height());
}
use dsq_formats::json::write_json_file;
use polars::prelude::*;
fn main() {
let df = df! {
"name" => ["Alice", "Bob"],
"age" => [30, 25],
}.unwrap();
write_json_file(&df, "output.json")
.expect("Failed to write JSON");
}
use dsq_formats::parquet::read_parquet_file;
fn main() {
let df = read_parquet_file("data.parquet")
.expect("Failed to read Parquet");
println!("Columns: {:?}", df.get_column_names());
}
use dsq_formats::detect_format;
fn main() {
let format = detect_format("data.csv")
.expect("Failed to detect format");
match format {
Format::Csv => println!("CSV file detected"),
Format::Json => println!("JSON file detected"),
Format::Parquet => println!("Parquet file detected"),
_ => println!("Other format"),
}
}
use dsq_formats::csv::{read_csv_file_with_options, CsvReadOptions};
fn main() {
let options = CsvReadOptions {
has_header: true,
delimiter: b';',
quote_char: Some(b'"'),
..Default::default()
};
let df = read_csv_file_with_options("data.csv", &options)
.expect("Failed to read CSV with options");
}
The library can automatically detect file formats based on:
use dsq_formats::detect_format;
let format = detect_format("unknown.dat")?;
Each format supports various configuration options:
delimiter: Field separator characterhas_header: Whether first row contains headersquote_char: Character for quoting fieldsnull_values: List of strings to interpret as NULLskip_rows: Number of rows to skipencoding: Character encodingpretty: Pretty-print outputindent: Indentation levelnull_handling: How to handle null valuescompression: Compression algorithm (snappy, gzip, lz4, zstd)row_group_size: Rows per row groupstatistics: Whether to compute column statisticsFor detailed API documentation, see docs.rs/dsq-formats.
Format readers and writers are optimized for:
Contributions are welcome! To add support for new formats:
See CONTRIBUTING.md for more details.
Licensed under either of:
at your option.