CSV

Read and manipulate CSV files

Overview

CSV tool allows you to read, write, and query CSV files.

The user points to a CSV file; the agent reads, filters, or writes rows and returns the result.

Diagram

CSVTool Flow

👤 User

🤖 Agent

🔧 CSVTool

✅ Result

Installation

bash
pip install "praisonai[tools]"

Quick Start

  1. Simple Usage
    python
    from praisonai_tools import CSVTool
    
    # Initialize
    csv_tool = CSVTool()
    
    # Read CSV
    data = csv_tool.read("data.csv")
    print(data)
  2. With Configuration

    Use the same tool with an agent — see Usage with Agent below, or pass env vars and options from the sections above.

Usage with Agent

python
from praisonaiagents import Agent
from praisonai_tools import CSVTool

agent = Agent(
    name="DataAnalyst",
    instructions="You help analyze CSV data.",
    tools=[CSVTool()]
)

response = agent.chat("Read sales.csv and summarize the data")
print(response)

Available Methods

read(path)

Read a CSV file.

python
from praisonai_tools import CSVTool

csv_tool = CSVTool()
data = csv_tool.read("data.csv")

write(path, data)

Write data to a CSV file.

python
csv_tool.write("output.csv", [{"name": "Alice", "age": 30}])

How It Works

Diagram
CSV fileToolAgentUserCSV fileToolAgentUserRequestCall toolQueryDataResultResponse

Best Practices

Read a schema first

Inspect column names before querying so the agent references real fields, not guesses.

Stream large files

For big CSVs, process in chunks so memory stays bounded.

Validate before writing

Confirm row shape before write so you don’t corrupt an existing file.


Related Tools