Struct csvsc::input::InputStreamBuilder [−][src]
Implementations
impl InputStreamBuilder[src]
pub fn from_readers<I>(readers: I) -> InputStreamBuilder where
I: IntoIterator<Item = ReaderSource>, [src]
I: IntoIterator<Item = ReaderSource>,
Start a transformation chain from a set of csv creaders.
This is what you need in case your CSVs are not comma separated or you need to adjust some parameters like escape character.
Example
use csvsc::prelude::*; use csv::ReaderBuilder; use encoding::all::UTF_8; let mut chain = InputStreamBuilder::from_readers(vec![ ReaderBuilder::new() .delimiter(b';') .from_path("test/assets/1.csv") .unwrap().into(), ReaderBuilder::new() .delimiter(b';') .from_path("test/assets/2.csv") .unwrap().into(), ]).build().unwrap();
pub fn from_paths<I, P>(paths: I) -> Result<InputStreamBuilder> where
I: IntoIterator<Item = P>,
P: AsRef<Path>, [src]
I: IntoIterator<Item = P>,
P: AsRef<Path>,
Start a transformation chain from a set of paths in the filesystem.
This is probably the easiest way to get started. It assumes comma separated fields, double quotes as field wrap and some other sensible defaults from csv crate
Example
use csvsc::prelude::*; let mut chain = InputStreamBuilder::from_paths(&[ "test/assets/chicken_north.csv", "test/assets/chicken_south.csv", ]).unwrap().build().unwrap();
From there you can chain the methods of the RowStream
trait.
pub fn with_encoding(self, encoding: EncodingRef) -> Self[src]
Use this encoding to decode the input files
Example
use csvsc::prelude::*; use encoding::all::WINDOWS_1252; let mut chain = InputStreamBuilder::from_paths(&[ "test/assets/windows1252/data.csv", ]).unwrap().with_encoding(WINDOWS_1252).build().unwrap();
pub fn with_source_col(self, colname: &str) -> Self[src]
Add a column with this name to every row with the path to the file where it comes from.
Example
use csvsc::prelude::*; let mut chain = InputStreamBuilder::from_paths(&[ "test/assets/1.csv", ]).unwrap().with_source_col("source").build().unwrap().into_iter(); assert_eq!(chain.next().unwrap().unwrap(), Row::from(vec!["1", "3", "test/assets/1.csv"]));
pub fn build(self) -> Result<InputStream>[src]
Build the InputStream from the parameters of this builder and return
it.
Auto Trait Implementations
impl !RefUnwindSafe for InputStreamBuilder
impl Send for InputStreamBuilder
impl Sync for InputStreamBuilder
impl Unpin for InputStreamBuilder
impl !UnwindSafe for InputStreamBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,