Struct polars::prelude::CsvReader [−][src]
Expand description
Create a new DataFrame by reading a csv file.
Example
use polars_core::prelude::*; use polars_io::prelude::*; use std::fs::File; fn example() -> Result<DataFrame> { CsvReader::from_path("iris_csv")? .infer_schema(None) .has_header(true) .finish() }
Fields
rechunk: bool
Aggregates chunk afterwards to a single chunk.
Implementations
Sets the chunk size used by the parser. This influences performance
Sets the CsvEncoding
Try to stop parsing when n
rows are parsed. During multithreaded parsing the upper bound n
cannot
be guaranteed.
Continue with next batch when a ParserError is encountered.
Set the CSV file’s schema. This only accepts datatypes that are implemented in the csv parser and expects a complete Schema.
It is recommended to use with_dtypes instead.
Skip the first n
rows during parsing.
Rechunk the DataFrame to contiguous memory after the CSV is parsed.
Set whether the CSV file has headers
Set the CSV file’s column delimiter as a byte character
Overwrite the schema with the dtypes in this given Schema. The given schema may be a subset of the total schema.
Set the CSV reader to infer the schema of the file
Arguments
max_records
- Maximum number of rows read for schema inference. Setting this toNone
will do a full table scan (slow).
Set the reader’s column projection. This counts from 0, meaning that
vec![0, 4]
would select the 1st and 5th column.
Columns to select/ project
Set the number of threads used in CSV reading. The default uses the number of cores of your cpu.
Note that this only works if this is initialized with CsvReader::from_path
.
Note that the number of cores is the maximum allowed number of threads.
The preferred way to initialize this builder. This allows the CSV file to be memory mapped and thereby greatly increases parsing performance.
Sets the size of the sample taken from the CSV file. The sample is used to get statistic about the file. These statistics are used to try to optimally allocate up front. Increasing this may improve performance.
Reduce memory consumption at the expense of performance
Trait Implementations
Auto Trait Implementations
impl<'a, R> RefUnwindSafe for CsvReader<'a, R> where
R: RefUnwindSafe,
impl<'a, R> UnwindSafe for CsvReader<'a, R> where
R: UnwindSafe,