polars_io::csv::read

Struct CsvReadOptions

Source
pub struct CsvReadOptions {
Show 20 fields pub path: Option<PathBuf>, pub rechunk: bool, pub n_threads: Option<usize>, pub low_memory: bool, pub n_rows: Option<usize>, pub row_index: Option<RowIndex>, pub columns: Option<Arc<[PlSmallStr]>>, pub projection: Option<Arc<Vec<usize>>>, pub schema: Option<SchemaRef>, pub schema_overwrite: Option<SchemaRef>, pub dtype_overwrite: Option<Arc<Vec<DataType>>>, pub parse_options: Arc<CsvParseOptions>, pub has_header: bool, pub chunk_size: usize, pub skip_rows: usize, pub skip_rows_after_header: usize, pub infer_schema_length: Option<usize>, pub raise_if_empty: bool, pub ignore_errors: bool, pub fields_to_cast: Vec<Field>,
}
Available on crate features csv or json only.

Fields§

§path: Option<PathBuf>§rechunk: bool§n_threads: Option<usize>§low_memory: bool§n_rows: Option<usize>§row_index: Option<RowIndex>§columns: Option<Arc<[PlSmallStr]>>§projection: Option<Arc<Vec<usize>>>§schema: Option<SchemaRef>§schema_overwrite: Option<SchemaRef>§dtype_overwrite: Option<Arc<Vec<DataType>>>§parse_options: Arc<CsvParseOptions>§has_header: bool§chunk_size: usize§skip_rows: usize§skip_rows_after_header: usize§infer_schema_length: Option<usize>§raise_if_empty: bool§ignore_errors: bool§fields_to_cast: Vec<Field>

Implementations§

Source§

impl CsvReadOptions

Source

pub fn get_parse_options(&self) -> Arc<CsvParseOptions>

Source

pub fn with_path<P: Into<PathBuf>>(self, path: Option<P>) -> Self

Source

pub fn with_rechunk(self, rechunk: bool) -> Self

Whether to makes the columns contiguous in memory.

Source

pub fn with_n_threads(self, n_threads: Option<usize>) -> Self

Number of threads to use for reading. Defaults to the size of the polars thread pool.

Source

pub fn with_low_memory(self, low_memory: bool) -> Self

Reduce memory consumption at the expense of performance

Source

pub fn with_n_rows(self, n_rows: Option<usize>) -> Self

Limits the number of rows to read.

Source

pub fn with_row_index(self, row_index: Option<RowIndex>) -> Self

Adds a row index column.

Source

pub fn with_columns(self, columns: Option<Arc<[PlSmallStr]>>) -> Self

Which columns to select.

Source

pub fn with_projection(self, projection: Option<Arc<Vec<usize>>>) -> Self

Which columns to select denoted by their index. The index starts from 0 (i.e. [0, 4] would select the 1st and 5th column).

Source

pub fn with_schema(self, schema: Option<SchemaRef>) -> Self

Set the schema to use for CSV file. The length of the schema must match the number of columns in the file. If this is None, the schema is inferred from the file.

Source

pub fn with_schema_overwrite(self, schema_overwrite: Option<SchemaRef>) -> Self

Overwrites the data types in the schema by column name.

Source

pub fn with_dtype_overwrite( self, dtype_overwrite: Option<Arc<Vec<DataType>>>, ) -> Self

Overwrite the dtypes in the schema in the order of the slice that’s given. This is useful if you don’t know the column names beforehand

Source

pub fn with_parse_options(self, parse_options: CsvParseOptions) -> Self

Sets the CSV parsing options. See map_parse_options for an easier way to mutate them in-place.

Source

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

Sets whether the CSV file has a header row.

Source

pub fn with_chunk_size(self, chunk_size: usize) -> Self

Sets the chunk size used by the parser. This influences performance.

Source

pub fn with_skip_rows(self, skip_rows: usize) -> Self

Number of rows to skip before the header row.

Source

pub fn with_skip_rows_after_header(self, skip_rows_after_header: usize) -> Self

Number of rows to skip after the header row.

Source

pub fn with_infer_schema_length( self, infer_schema_length: Option<usize>, ) -> Self

Number of rows to use for schema inference. Pass None to use all rows.

Source

pub fn with_raise_if_empty(self, raise_if_empty: bool) -> Self

Whether to raise an error if the frame is empty. By default an empty DataFrame is returned.

Source

pub fn with_ignore_errors(self, ignore_errors: bool) -> Self

Continue with next batch when a ParserError is encountered.

Source

pub fn map_parse_options<F: Fn(CsvParseOptions) -> CsvParseOptions>( self, map_func: F, ) -> Self

Apply a function to the parse options.

Source§

impl CsvReadOptions

Source

pub fn try_into_reader_with_file_path( self, path: Option<PathBuf>, ) -> PolarsResult<CsvReader<File>>

Creates a CSV reader using a file path.

§Panics

If both self.path and the path parameter are non-null. Only one of them is to be non-null.

Source

pub fn into_reader_with_file_handle<R: MmapBytesReader>( self, reader: R, ) -> CsvReader<R>

Creates a CSV reader using a file handle.

Source§

impl CsvReadOptions

Source

pub fn update_with_inference_result( &mut self, si_result: &SchemaInferenceResult, )

Note: This does not update the schema from the inference result.

Trait Implementations§

Source§

impl Clone for CsvReadOptions

Source§

fn clone(&self) -> CsvReadOptions

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 CsvReadOptions

Source§

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

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

impl Default for CsvReadOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for CsvReadOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for CsvReadOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CsvReadOptions

Source§

fn eq(&self, other: &CsvReadOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CsvReadOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CsvReadOptions

Source§

impl StructuralPartialEq for CsvReadOptions

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> Ungil for T
where T: Send,