Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI CSV Search Tool

From Leeroopedia
Knowledge Sources
Domains Tools, RAG, Data_Search
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for performing semantic search over CSV file contents using RAG provided by CrewAI.

Description

The CSVSearchTool class extends RagTool to enable semantic search over tabular CSV data. It provides two operational modes using dual Pydantic schemas: FixedCSVSearchToolSchema for pre-configured CSV files (where the csv path is set during initialization) and CSVSearchToolSchema for dynamic mode (where the csv path is provided at runtime). When initialized with a csv parameter, the tool adds the CSV to the RAG index using DataType.CSV and switches to the fixed schema with a dynamically generated description. The _run method accepts a search_query, optional csv path, similarity_threshold, and limit parameters, adding the CSV to the index if provided and delegating to the parent RagTool's _run method. The CSV parameter accepts both file paths and URLs.

Usage

Use this tool when CrewAI agents need to search for relevant information within CSV data using natural language queries, supporting both pre-indexed and runtime-specified CSV sources.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/tools/csv_search_tool/csv_search_tool.py
  • Lines: 1-51

Signature

class CSVSearchTool(RagTool):
    name: str = "Search a CSV's content"
    description: str = "A tool that can be used to semantic search a query from a CSV's content."
    args_schema: type[BaseModel] = CSVSearchToolSchema

    def __init__(self, csv: str | None = None, **kwargs): ...
    def add(self, csv: str) -> None: ...
    def _run(self, search_query: str, csv: str | None = None,
             similarity_threshold: float | None = None, limit: int | None = None) -> str: ...

Import

from crewai_tools import CSVSearchTool

I/O Contract

Inputs

Name Type Required Description
search_query str Yes Natural language query to search the CSV content
csv str or None No File path or URL of a CSV file (constructor for fixed, runtime for dynamic)
similarity_threshold float or None No Minimum similarity score for results
limit int or None No Maximum number of results to return

Outputs

Name Type Description
_run() returns str Semantically relevant content from the CSV matching the search query

Usage Examples

Basic Usage

from crewai_tools import CSVSearchTool

# Fixed CSV mode
tool = CSVSearchTool(csv="./data/employees.csv")
result = tool.run(search_query="Who works in the engineering department?")

# Dynamic CSV mode
tool = CSVSearchTool()
result = tool.run(search_query="revenue data", csv="./data/financials.csv")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment