How to pass in a CSV file
Is it possible to pass in a CSV list of, for me URLs, but for others maybe something else, and then the agents work through the list each in turn? In which case, how do I code that?
I having a similar problem. I don't know how to pass in a text file from my computer.
@claude Please review this issue and provide a solution
@claude Please review this issue and provide a solution
Claude finished @MervinPraison's task —— View job • claude/issue-23-20250530_125338 • Create PR ➔
✅ CSV Processing Solution for Issue #23
I've analyzed the codebase and created a comprehensive solution for processing CSV files with PraisonAI agents.
Todo List:
- [x] Read repository guidelines (CLAUDE.md)
- [x] Explore existing CSV tools and file processing capabilities
- [x] Examine agent examples for sequential processing patterns
- [x] Create example code for CSV processing with agents
- [x] Document the solution with multiple use cases
- [x] Test the implementation
✅ Answer: YES, it's absolutely possible!
PraisonAI provides multiple ways to process CSV files with agents working through lists sequentially.
🚀 Quick Solution (Simplest approach)
For your exact use case - processing a CSV list of URLs sequentially:
from praisonaiagents import Agent, Task, PraisonAIAgents
# Create your agent
agent = Agent(
name="URLProcessor",
instructions="Analyze each URL from the CSV file"
)
# Create a loop task that processes each CSV row
task = Task(
description="Process each URL from the CSV",
agent=agent,
task_type="loop", # This enables CSV loop processing
input_file="your_urls.csv" # Your CSV file with URLs
)
# Run the agents
agents = PraisonAIAgents(
agents=[agent],
tasks=[task],
process="workflow"
)
agents.start()
📁 CSV File Format
Your CSV can be simple:
url
https://example.com
https://github.com
https://stackoverflow.com
Or with additional columns:
url,description,priority
https://example.com,Example site,high
https://github.com,Code platform,medium
📦 Complete Examples Created
I've created comprehensive examples in the repository:
-
simple-csv-url-processor.py- Direct solution for your use case -
csv-processing-agents.py- 4 different methods including:- Simple loop processing (easiest)
- Manual CSV processing with tools
- URL-specific processing
- Advanced processing with validation
-
CSV_PROCESSING_README.md- Complete documentation
🛠 Built-in CSV Tools Available
PraisonAI includes robust CSV tools:
from praisonaiagents.tools import read_csv, write_csv, merge_csv
# Read CSV files with advanced options
data = read_csv("input.csv", delimiter=",", header=0)
# Write data to CSV
write_csv("output.csv", data)
# Merge multiple CSV files
merge_csv(["file1.csv", "file2.csv"], "merged.csv")
📋 Setup Requirements
- Install PraisonAI Agents:
pip install praisonaiagents - Set API key:
export OPENAI_API_KEY=your_key - Optional:
pip install pandas(for advanced CSV operations)
💡 For Text Files
@scaruslooner For text files from your computer, you can:
- Convert to CSV format, or
- Use file tools to read line by line, or
- Process the text file directly with agents
🎯 Key Benefits
- ✅ Sequential Processing: Agents work through each item in order
- ✅ Automatic Looping: Built-in
task_type="loop"handles iteration - ✅ Flexible Input: Support for various CSV formats and columns
- ✅ Error Handling: Robust processing with validation options
- ✅ Multiple Patterns: Choose the approach that fits your needs
The examples are ready to use and demonstrate exactly how to process CSV lists with agents working through each item sequentially!