Crates.io | dcsv |
lib.rs | dcsv |
version | 0.3.4-beta.2 |
source | src |
created_at | 2022-05-10 15:18:39.496901 |
updated_at | 2024-01-21 09:53:02.760526 |
description | Dyanmic csv reader,writer,editor |
homepage | https://github.com/simhyeon/dcsv |
repository | https://github.com/simhyeon/dcsv |
max_upload_size | |
id | 584040 |
size | 6,364,953 |
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
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 many 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);
Most of the time, 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.