Field Labeled CSV Reader

Parameters and methods of FieldLabeledCSVReader, which converts each CSV row into a field-labeled document.

FieldLabeledCSVReader is a reader class that converts CSV rows into field-labeled text documents.

Parameters

ParameterTypeDefaultDescription
chunk_titleOptional[Union[str, List[str]]]NoneTitle added at the top of each entry. A list rotates through entries
field_namesOptional[List[str]]NoneCustom labels for CSV fields. Column headers are used when not provided
format_headersboolTrueFormat column headers by replacing underscores with spaces and applying title case
skip_empty_fieldsboolTrueSkip fields with empty values in the output

FieldLabeledCSVReader also accepts the base Reader constructor parameters, except chunk and chunking_strategy. Chunking is disabled; each CSV row becomes one document.

Methods

read()

Reads a CSV file and returns one field-labeled document per row.

ParameterTypeDefaultDescription
fileUnion[Path, IO[bytes]]RequiredPath to the CSV file or a binary file-like object
delimiterstr","Character used to separate fields in the CSV
quotecharstr'"'Character used to quote fields in the CSV
nameOptional[str]NoneName override for the resulting documents

Open non-Path inputs in binary mode (rb). The reader decodes the returned bytes with its configured encoding.

async_read()

The async variant of read(). It accepts the same parameters, plus:

ParameterTypeDefaultDescription
page_sizeint1000Number of rows per page when paginating large files