arrow_csv::reader

Struct Format

Source
pub struct Format {
    header: bool,
    delimiter: Option<u8>,
    escape: Option<u8>,
    quote: Option<u8>,
    terminator: Option<u8>,
    comment: Option<u8>,
    null_regex: NullRegex,
    truncated_rows: bool,
}
Expand description

The format specification for the CSV file

Fields§

§header: bool§delimiter: Option<u8>§escape: Option<u8>§quote: Option<u8>§terminator: Option<u8>§comment: Option<u8>§null_regex: NullRegex§truncated_rows: bool

Implementations§

Source§

impl Format

Source

pub fn with_header(self, has_header: bool) -> Self

Specify whether the CSV file has a header, defaults to true

When true, the first row of the CSV file is treated as a header row

Source

pub fn with_delimiter(self, delimiter: u8) -> Self

Specify a custom delimiter character, defaults to comma ','

Source

pub fn with_escape(self, escape: u8) -> Self

Specify an escape character, defaults to None

Source

pub fn with_quote(self, quote: u8) -> Self

Specify a custom quote character, defaults to double quote '"'

Source

pub fn with_terminator(self, terminator: u8) -> Self

Specify a custom terminator character, defaults to CRLF

Source

pub fn with_comment(self, comment: u8) -> Self

Specify a comment character, defaults to None

Lines starting with this character will be ignored

Source

pub fn with_null_regex(self, null_regex: Regex) -> Self

Provide a regex to match null values, defaults to ^$

Source

pub fn with_truncated_rows(self, allow: bool) -> Self

Whether to allow truncated rows when parsing.

By default this is set to false and will error if the CSV rows have different lengths. When set to true then it will allow records with less than the expected number of columns and fill the missing columns with nulls. If the record’s schema is not nullable, then it will still return an error.

Source

pub fn infer_schema<R: Read>( &self, reader: R, max_records: Option<usize>, ) -> Result<(Schema, usize), ArrowError>

Infer schema of CSV records from the provided reader

If max_records is None, all records will be read, otherwise up to max_records records are read to infer the schema

Returns inferred schema and number of records read

Source

fn build_reader<R: Read>(&self, reader: R) -> Reader<R>

Build a [csv::Reader] for this Format

Source

fn build_parser(&self) -> Reader

Build a [csv_core::Reader] for this Format

Trait Implementations§

Source§

impl Clone for Format

Source§

fn clone(&self) -> Format

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Format

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Format

Source§

fn default() -> Format

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Format

§

impl RefUnwindSafe for Format

§

impl Send for Format

§

impl Sync for Format

§

impl Unpin for Format

§

impl UnwindSafe for Format

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,