Skip to content

renanliberato/csv-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 CSV Worker

Supercharge your CSV files with AI-powered data processing

CSV Worker is a powerful command-line tool that leverages OpenRouter's AI models to process and enrich your CSV data. Whether you need to add new columns with AI-generated content or transform existing data, CSV Worker makes it simple and efficient.

✨ Features

  • 🤖 AI-Powered Processing: Uses OpenRouter API with Google Gemini 2.5 Flash Lite for fast, intelligent data processing
  • 📊 Flexible Operations: Add new columns or edit existing ones with custom prompts
  • 🔄 Batch Processing: Group rows by columns for efficient batch operations
  • ⚡ Real-time Updates: See your CSV file update as each row is processed
  • 🛡️ Safe Operations: Optional output file preserves your original data

🛠️ Installation

From Source

git clone https://github.com/yourusername/csv-worker.git
cd csv-worker
pip install -e .

Dependencies

  • Python 3.7+
  • requests
  • python-dotenv

🚀 Quick Start

  1. Set up your OpenRouter API key

    export OPENROUTER_API_KEY="your-api-key-here"
    # or create a .env file with: OPENROUTER_API_KEY=your-api-key-here
  2. Process your first CSV

    csv-worker data.csv --add-column "sentiment" --prompt "Analyze the sentiment of this text"

📖 Usage

Basic Syntax

csv-worker <csv_file> [OPTIONS] --prompt "<your prompt>"

Options

Option Description
--add-column COLUMN Add a new column with the specified name
--edit-column COLUMN Edit an existing column
--prompt PROMPT Your prompt for the AI (required)
--system-prompt PROMPT Custom system prompt (default: helpful assistant)
--group-by COLUMNS Comma-separated columns to group by for batch processing
--output, -o FILE Output file path (preserves original if specified)

Examples

Add a sentiment analysis column

csv-worker reviews.csv --add-column "sentiment" --prompt "Classify the sentiment as positive, negative, or neutral"

Extract entities from text

csv-worker articles.csv --add-column "entities" --prompt "Extract named entities from this text"

Batch process by category

csv-worker products.csv --add-column "description" --group-by "category" --prompt "Generate a compelling product description"

Edit existing column

csv-worker emails.csv --edit-column "subject" --prompt "Make this subject line more engaging"

Preserve original file

csv-worker data.csv --add-column "processed" --prompt "Process this data" --output "processed_data.csv"

🎯 Use Cases

  • Data Enrichment: Add AI-generated insights to existing datasets
  • Text Analysis: Perform sentiment analysis, entity extraction, or classification
  • Content Generation: Create descriptions, summaries, or transformations
  • Data Cleaning: Standardize and normalize text data
  • Batch Processing: Efficiently process large datasets by grouping

🔧 Configuration

Create a .env file in your project directory:

OPENROUTER_API_KEY=your_api_key_here

📝 Tips

  • Use specific, clear prompts for better results
  • Group similar rows together with --group-by for more consistent batch processing
  • Always test with a small sample first using the --output option
  • The tool processes rows sequentially and saves after each operation for data safety

Made with ❤️ for data enthusiasts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors