Version: latest
agrag.loaders.records.CsvLoader
Bases: RecordLoader
Reads CSV and TSV files as one record document per row.
With csv_mode=TABLE the loader yields one prose Document for the whole
source instead.
Attributes:
- extensions – The
.csvand.tsvextensions.
Functions:
- is_available – Return whether the package that the loader's extra installs is present.
- load – Yield one record Document per row, or one prose Document for a table.
extensions
extensions = frozenset({'.csv', '.tsv'})
extra
extra: str | None = None
extra_module
extra_module: str | None = None
family
family = DocumentFamily.RECORD
is_available
is_available() -> bool
Return whether the package that the loader's extra installs is present.
A loader with no extra is always available. The check looks the module up without importing it, so an installed package that fails to import still counts.
load
load(source:SourceRef, stream:BinaryIO, opts:ReadOptions, *, start_at:int = 0) -> Iterator[Document]
Yield one record Document per row, or one prose Document for a table.
Parameters:
- source (
SourceRef) – The source to read. - stream (
BinaryIO) – The open binary stream for the source. - opts (
ReadOptions) – The read options.csv_delimiteroverrides the separator.csv_mode=TABLEreads the whole source as one prose Document. - start_at (
int) – The record index to resume from.
Yields:
Document– One record Document per row in file order, or one prose Document inDocument– table mode.
Raises:
MalformedRecordError– A row fails to parse.
mime_types
mime_types: frozenset[str] = frozenset()