> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CSV

> The CsvTools toolkit enables an Agent to read and query CSV files.

**CsvTools** enable an Agent to read and query CSV files.

## Prerequisites

The following example requires the `duckdb` and `openai` libraries. Without `duckdb`, the `query_csv_file` function is disabled.

```shell theme={null}
uv pip install -U duckdb openai
```

## Example

The following agent will download the IMDB csv file and analyze it.

```python cookbook/91_tools/csv_tools.py theme={null}
from pathlib import Path

import httpx
from agno.agent import Agent
from agno.tools.csv_toolkit import CsvTools

url = "https://agno-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv"
response = httpx.get(url)

imdb_csv = Path(__file__).parent.joinpath("imdb.csv")
imdb_csv.parent.mkdir(parents=True, exist_ok=True)
imdb_csv.write_bytes(response.content)

agent = Agent(
    tools=[CsvTools(csvs=[imdb_csv])],
    description="You are a comprehensive CSV data analyst with all processing capabilities.",
    instructions=[
        "Help users with complete CSV data analysis and processing",
        "First always get the list of files",
        "Then check the columns in the file",
        "Run queries and provide detailed analysis",
        "Support all CSV operations and transformations",
    ],
    markdown=True,
)

agent.print_response(
    "Analyze the IMDB movie dataset. Show me the top 10 highest-rated movies and their directors.",
    markdown=True,
)
```

## Toolkit Params

| Parameter               | Type                     | Default | Description                                                            |
| ----------------------- | ------------------------ | ------- | ---------------------------------------------------------------------- |
| `csvs`                  | `List[Union[str, Path]]` | `None`  | A list of CSV files or paths to be processed or read.                  |
| `row_limit`             | `int`                    | `None`  | The maximum number of rows to process from each CSV file.              |
| `duckdb_connection`     | `Any`                    | `None`  | Specifies a connection instance for DuckDB database operations.        |
| `duckdb_kwargs`         | `Dict[str, Any]`         | `None`  | A dictionary of keyword arguments for configuring DuckDB operations.   |
| `enable_read_csv_file`  | `bool`                   | `True`  | Enables the functionality to read data from specified CSV files.       |
| `enable_list_csv_files` | `bool`                   | `True`  | Enables the functionality to list all available CSV files.             |
| `enable_get_columns`    | `bool`                   | `True`  | Enables the functionality to read the column names from CSV files.     |
| `enable_query_csv_file` | `bool`                   | `True`  | Enables the functionality to execute queries on data within CSV files. |
| `all`                   | `bool`                   | `False` | Enables all functionality when set to True.                            |

## Toolkit Functions

| Function         | Description                                      |
| ---------------- | ------------------------------------------------ |
| `list_csv_files` | Lists all available CSV files.                   |
| `read_csv_file`  | This function reads the contents of a csv file   |
| `get_columns`    | This function returns the columns of a csv file  |
| `query_csv_file` | This function queries the contents of a csv file |

## Developer Resources

* [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/csv_toolkit.py)
