Crates.io | datatroll |
lib.rs | datatroll |
version | 0.1.3 |
source | src |
created_at | 2024-01-22 19:36:48.574429 |
updated_at | 2024-02-06 19:10:47.765918 |
description | a robust and user-friendly Rust library for efficiently loading, manipulating, and exporting data stored in CSV files. |
homepage | https://github.com/aymenhta/datatroll |
repository | https://github.com/aymenhta/datatroll |
max_upload_size | |
id | 1109091 |
size | 51,616 |
datatroll is a robust and user-friendly Rust library for efficiently loading, manipulating, and exporting data stored in CSV files. Say goodbye to tedious hand-coding data parsing and welcome a streamlined workflow for wrangling your data with ease.
Add rust-csv-wrangler to your project with Cargo:
[dependencies]
datatroll = "0.1.0"
Import the library and start wrangling your data:
use datatroll::{Cell, Sheet};
fn main() {
// Read data from a CSV file
let mut sheet = Sheet::new();
if let Err(err) = sheet.load_data("input.csv") {
eprintln!("Error loading data: {}", err);
} else {
println!("Data loaded successfully from input.csv");
}
// drop all the rows in which the review is less than 4.0
sheet.drop_rows("review", |c| {
if let Cell::Float(r) = c {
return *r < 4.0;
}
false
});
// calculate the variance of the review column
let variance = sheet.variance("review").unwrap();
println!("variance for review is: {variance}");
// Write the transformed data to a new CSV file
if let Err(err) = sheet.export("output.csv") {
eprintln!("Error exporting data: {}", err);
} else {
println!("Data exported successfully to output.csv");
}
}