Struct csvsc::input::InputStreamBuilder[][src]

pub struct InputStreamBuilder { /* fields omitted */ }

Implementations

impl InputStreamBuilder[src]

pub fn from_readers<I>(readers: I) -> InputStreamBuilder where
    I: IntoIterator<Item = ReaderSource>, 
[src]

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]

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.