Download loda-rust/rust_project/loda-rust-cli/src/common/parse_csv_file.rs from Alignment-Lab-AI/ARC-stuff: direct link, hf CLI and curl.
- Browser
- Download file 396 Bytes
-
https://huggingface.co/datasets/Alignment-Lab-AI/ARC-stuff/resolve/main/loda-rust/rust_project/loda-rust-cli/src/common/parse_csv_file.rs
- Command line
-
hf download hf://datasets/Alignment-Lab-AI/ARC-stuff/loda-rust/rust_project/loda-rust-cli/src/common/parse_csv_file.rs
-
curl -L -o parse_csv_file.rs https://huggingface.co/datasets/Alignment-Lab-AI/ARC-stuff/resolve/main/loda-rust/rust_project/loda-rust-cli/src/common/parse_csv_file.rs
396 Bytes
| use std::error::Error; | |
| use std::io::BufReader; | |
| use std::path::Path; | |
| use std::fs::File; | |
| use serde::de::DeserializeOwned; | |
| use super::parse_csv_data; | |
| pub fn parse_csv_file<D: DeserializeOwned>(path: &Path) -> Result<Vec<D>, Box<dyn Error>> { | |
| let file = File::open(path)?; | |
| let mut reader = BufReader::new(file); | |
| let records: Vec<D> = parse_csv_data::<D>(&mut reader)?; | |
| Ok(records) | |
| } | |