8 releases

Uses new Rust 2021

new 0.3.1 Jun 30, 2022
0.3.0 Jun 21, 2022
0.2.0 Jun 16, 2022
0.1.4 Jun 5, 2022
0.1.1 May 30, 2022

#477 in Text processing

Download history 38/week @ 2022-05-10 5/week @ 2022-05-17 17/week @ 2022-05-24 115/week @ 2022-05-31 35/week @ 2022-06-07 55/week @ 2022-06-14 59/week @ 2022-06-21 44/week @ 2022-06-28

213 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

82KB
2K SLoC

dcsv

Dynamic csv reader, editor, and writer library.

If you use structured csv data, use csv crate

If you want higher wrapper around csv editing, use ced

changes

Feature

  • Read csv which has undecided format
  • Optionally validate csv values
  • Edit csv values
  • Write to file

Basic usage

Refer Usage for more usages. Docs.rs is also useful in general.

Include dcsv in cargo.toml file first.

[dependencies]
dcsv = "*"
// Trait VCont is required to use most methods
use dcsv::{Reader, VirtualData, Value, VCont};
use std::fs::File;

let data: VirtualData = Reader::new()
    .use_delimiter(';')      // Default is comma
    .use_line_delimiter('|') // Default is '\n, \r\n'
    .data_from_stream(
        BufReader::new(
            File::open("file_name.csv")
                .expect("Failed to read file")
        )
    )
    .expect("Failed to retrieve csv value from file");

// import VCont trait before use
// Refer docs.rs for various VirtualData methods
let value : Option<&Value> = data.get_cell(1,1);

Why?

Most of the times, well known csv crate is much more performant and eaiser to use because csv format doesn't change a lot. However there are cases where program expects undecided csv formats and contents, which means program has to ensure every value is compatible with expected standard. In such case, csv crate's type guarantee is painful to handle with.

See the examples for usages.

Not yet

  • Fully comptaible with csv spec

Dependencies

~1–1.3MB
~37K SLoC