pub struct Format { /* private fields */ }
Expand description
The format specification for the CSV file
Implementations§
Source§impl Format
impl Format
Sourcepub fn with_header(self, has_header: bool) -> Self
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
Sourcepub fn with_delimiter(self, delimiter: u8) -> Self
pub fn with_delimiter(self, delimiter: u8) -> Self
Specify a custom delimiter character, defaults to comma ','
Sourcepub fn with_escape(self, escape: u8) -> Self
pub fn with_escape(self, escape: u8) -> Self
Specify an escape character, defaults to None
Sourcepub fn with_quote(self, quote: u8) -> Self
pub fn with_quote(self, quote: u8) -> Self
Specify a custom quote character, defaults to double quote '"'
Sourcepub fn with_terminator(self, terminator: u8) -> Self
pub fn with_terminator(self, terminator: u8) -> Self
Specify a custom terminator character, defaults to CRLF
Sourcepub fn with_comment(self, comment: u8) -> Self
pub fn with_comment(self, comment: u8) -> Self
Specify a comment character, defaults to None
Lines starting with this character will be ignored
Sourcepub fn with_null_regex(self, null_regex: Regex) -> Self
pub fn with_null_regex(self, null_regex: Regex) -> Self
Provide a regex to match null values, defaults to ^$
Sourcepub fn with_truncated_rows(self, allow: bool) -> Self
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.
Sourcepub fn infer_schema<R: Read>(
&self,
reader: R,
max_records: Option<usize>,
) -> Result<(Schema, usize), ArrowError>
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