Struct polars_io::csv::CsvReader [−][src]
pub struct CsvReader<'a, R> where
R: MmapBytesReader, { /* fields omitted */ }
csv-file
only.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()
}
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
Set the comment character. Lines starting with this character will be ignored.
Set values that will be interpreted as missing/ null. Note that any value you set as null value will not be escaped, so if quotation marks are part of the null value you should include them.
Overwrite the schema with the dtypes in this given Schema. The given schema may be a subset of the total schema.
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
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
Set the char
used as quote char. The default is b'"'
. If set to [None]
quoting is disabled.
This is supported on crate feature temporal
only.
temporal
only.Automatically try to parse dates/ datetimes and time. If parsing fails, columns remain of dtype [DataType::Utf8]
.
private
only.