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
| Parameter | Type | Default | Description |
|---|---|---|---|
chunk_title | Optional[Union[str, List[str]]] | None | Title added at the top of each entry. A list rotates through entries |
field_names | Optional[List[str]] | None | Custom labels for CSV fields. Column headers are used when not provided |
format_headers | bool | True | Format column headers by replacing underscores with spaces and applying title case |
skip_empty_fields | bool | True | Skip 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
file | Union[Path, IO[bytes]] | Required | Path to the CSV file or a binary file-like object |
delimiter | str | "," | Character used to separate fields in the CSV |
quotechar | str | '"' | Character used to quote fields in the CSV |
name | Optional[str] | None | Name 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:
| Parameter | Type | Default | Description |
|---|---|---|---|
page_size | int | 1000 | Number of rows per page when paginating large files |