Crates.io | csv-pipeline |
lib.rs | csv-pipeline |
version | 0.4.0 |
source | src |
created_at | 2023-01-11 13:20:33.674457 |
updated_at | 2023-05-25 06:52:04.061242 |
description | CSV processing library |
homepage | https://github.com/probablykasper/csv-pipeline#readme |
repository | https://github.com/probablykasper/csv-pipeline |
max_upload_size | |
id | 756411 |
size | 41,199 |
CSV processing library inspired by csvsc
use csv_pipeline::{Pipeline, Transformer};
let source = "\
Person,Score\n\
A,1\n\
A,8\n\
B,3\n\
B,4\n";
let reader = csv::Reader::from_reader(source.as_bytes());
let csv = Pipeline::from_reader(reader)
.unwrap()
.map(|_headers, row| Ok(row))
// Transform into a new csv
.transform_into(|| {
vec![
// Keep every Person
Transformer::new("Person").keep_unique(),
// Sum the scores into a "Total score" column
Transformer::new("Total score").from_col("Score").sum(0),
]
})
.collect_into_string()
.unwrap();
assert_eq!(
csv,
"Person,Total score\n\
A,9\n\
B,7\n"
);
Install Rust.
Run tests:
cargo test
CHANGELOG.md
Cargo.toml
cargo test
cargo publish
v#.#.#