read_until_start_and_infer_schema

Function read_until_start_and_infer_schema 

Source
pub fn read_until_start_and_infer_schema(
    options: &CsvReadOptions,
    projected_schema: Option<Arc<Schema<DataType>>>,
    inspect_first_content_row_fn: Option<Box<dyn FnMut(&[u8]) + '_>>,
    reader: &mut CompressedReader,
) -> Result<(Schema<DataType>, MemSlice), PolarsError>
Available on crate feature polars-io only.
Expand description

Reads bytes from reader until the CSV starting point is reached depending on the options.

Returns the inferred schema and leftover bytes not yet consumed, which may be empty. The leftover bytes + reader.read_next_slice is guaranteed to start at first real content row.

inspect_first_content_row_fn allows looking at the first content row, this is where parsing will start. Beware even if the function is provided it’s not guaranteed that the returned value will be Some, since it the CSV may be incomplete.

The reading is done in an iterative streaming fashion

This function isn’t perf critical but would increase binary-size so don’t inline it.