DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / CSVKnowledgeSource
Class knowledge

CSVKnowledgeSource: Reference Guide

By DevShelfHub

Loads tabular CSV data into the knowledge store with per-row embeddings.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is CSVKnowledgeSource?

CSVKnowledgeSource ingests delimiter-separated tables where each row becomes an embeddable document. That row-wise strategy fits FAQ exports, glossary dumps, and lightweight product catalogs where cells are mostly short strings rather than huge blobs. Retrieval quality hinges on column semantics: include a header row with meaningful names so chunk text preserves context, and deduplicate rows before indexing to avoid embedding identical answers hundreds of times.

Because every row is embedded independently, wide CSVs with dozens of text-heavy columns can explode vector counts and storage under .crewai faster than PDF sources that chunk more aggressively. Trim columns to what agents actually need, or pre-process with pandas to concatenate key fields into a single text column per row.

When agents need aggregations (sums, joins, windowed metrics), pair retrieval with a SQL or Python tool instead of expecting the vector store to behave like a database — CSVKnowledgeSource answers "which rows look like this question", not "compute Q3 revenue".

When to Use

Tabular text data.

Use Cases

  • FAQ tables
  • Glossaries

Key Features

  • Row-wise embedding

When NOT to Use

Numeric analytics — use a SQL tool instead.

Notes

Delimiter and encoding surprises

Windows exports sometimes use latin-1 while your embedder expects UTF-8. Normalize files in CI and fail fast on mojibake rather than silently embedding garbage characters.

Headerless CSVs

Without headers, embeddings lose column meaning. Add a preprocessing step that prefixes each cell with its logical field name before indexing.

Row cardinality vs recall

Very wide tables produce many near-duplicate embeddings. Collapse related columns or summarize rows to improve cosine separation between concepts.

Refresh strategy

When the upstream system regenerates the CSV nightly, delete or rebuild the backing vector slice for that source version so agents never retrieve stale pricing.

Import

python
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource

Key Parameters

Parameter Type Default Purpose
file_path str CSV path.

Code Examples

FAQ export

python
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource

src = CSVKnowledgeSource(file_path='support/faq.csv')

Crew-level attachment

python
from crewai import Agent, Task, Crew, Process
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource

src = CSVKnowledgeSource(file_path='catalog/skus.csv')
agent = Agent(role='Sales helper', goal='Answer SKU questions', backstory='Use knowledge only.')
task = Task(description='What is the warranty for SKU {sku}?', expected_output='One paragraph', agent=agent)

Crew(agents=[agent], tasks=[task], knowledge_sources=[src], process=Process.sequential).kickoff(inputs={'sku': 'A-12'})

Combine with agent-scoped knowledge

python
from crewai import Agent
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource

public = CSVKnowledgeSource(file_path='data/public_faq.csv')
agent = Agent(role='Support', goal='Answer', backstory='...', knowledge_sources=[public])

Common Mistakes

❌ Embedding a 200 MB CSV unchanged

✅ Filter columns, deduplicate rows, or switch to a warehouse tool for analytics-scale data.

CSVKnowledgeSource FAQ

What is CSVKnowledgeSource in CrewAI?

Loads tabular CSV data into the knowledge store with per-row embeddings. CSVKnowledgeSource ingests delimiter-separated tables where each row becomes an embeddable document. That row-wise strategy fits FAQ exports, glossary dumps, and lightweight product catalogs where cells are mostly short strings rather than huge blobs. Retrieval quality hinges on column semantics: include a header row with meaningful names so chunk text preserves context, and deduplicate rows before indexing to avoid embedding identical answers hundreds of times. Because ever…

Which package defines the CrewAI class CSVKnowledgeSource?

DevShelfHub maps CSVKnowledgeSource to Python module crewai.knowledge.source (package path crewai.knowledge.source in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use CSVKnowledgeSource?

Tabular text data.

When should I avoid using CSVKnowledgeSource?

Numeric analytics — use a SQL tool instead.

How do I import CSVKnowledgeSource in Python?

from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.