CSV Reader

Convert CSV files into knowledge base documents with CSVReader.

CSVReader converts each CSV row into a document with RowChunking by default.

csv_reader.py
from pathlib import Path

from agno.knowledge.reader.csv_reader import CSVReader

reader = CSVReader()

csv_path = Path("tmp/test.csv")
csv_path.parent.mkdir(parents=True, exist_ok=True)
csv_path.write_text(
    "name,department\nJordan,Engineering\nTaylor,Product\n",
    encoding="utf-8",
)

documents = reader.read(csv_path)
for document in documents:
    print(document.content)

Run the Reader

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U "agno[csv]"

Run the script

python csv_reader.py

Reader Parameters

ParameterTypeDefaultDescription
chunking_strategyOptional[ChunkingStrategy]RowChunking()Strategy used to chunk documents

CSVReader also accepts the base Reader constructor parameters.

Pass delimiter and quotechar to read() for other CSV dialects.

CSVReader.async_read() accepts page_size to batch files with more than 10 rows before applying the chunking strategy.

Next Steps

TaskGuide
Configure row chunkingCSV Row Chunking
Label fields in each rowField-Labeled CSV Reference
Compare available readersReaders Overview