#csv #schema #python #validate #infer #data-type #csv-input

baskerville

Infer and validate data-type schemas in Rust

3 releases (breaking)

0.3.0 Mar 3, 2024
0.2.0 Sep 11, 2023
0.1.0 Sep 6, 2023

#929 in Database interfaces

46 downloads per month

MIT license

625KB
615 lines


Crates.io docs.rs GitHub

Infer and validate data-type schemas in Rust and Python.

RustPython

Installation

cargo add baskerville

Example

# mascots.csv
Name,LOC,Species
Ferris,42,Crab
Corro,7,Urchin
use baskerville::{infer_csv_with_options, CsvInput, InferOptions};

fn main() {
    let fields = infer_csv_with_options(
        CsvInput::Path("mascots.csv"),
        &mut InferOptions {
            has_headers: true,
            ..InferOptions::default()
        },
    )
    .unwrap();
    println!("{fields}");
}

Output:

╭──────┬─────────┬─────────╮
│ Name │ LOC     │ Species │
├──────┼─────────┼─────────┤
│ Text │ Integer │ Text    │
│      │ Float   │         │
│      │ Text    │         │
╰──────┴─────────┴─────────╯

Contributing

Versioning

The repo bases versioning from Conventional Commits

Dependencies

~3–9.5MB
~76K SLoC