CSV Reader
Convert CSV files into knowledge base documents with CSVReader.
CSVReader converts each CSV row into a document with RowChunking by default.
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/activateInstall dependencies
uv pip install -U "agno[csv]"Run the script
python csv_reader.pyReader Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
chunking_strategy | Optional[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
| Task | Guide |
|---|---|
| Configure row chunking | CSV Row Chunking |
| Label fields in each row | Field-Labeled CSV Reference |
| Compare available readers | Readers Overview |