Skip to main content
Version: 0.0.5 (stable)

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:

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_delimiter overrides the separator. csv_mode=TABLE reads 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 in
  • Document – table mode.

Raises:

mime_types​

mime_types: frozenset[str] = frozenset()