Clean, filter, sort, dedupe, join and aggregate CSV files with Python after detecting encoding, delimiter and number formats; the input file is never overwritten.
---
name: csv-data-processor
description: Filters, sorts, deduplicates, joins, aggregates and reshapes CSV files with Python (csv module or pandas) after detecting encoding, delimiter, header and number formats, and writes the result to a new file without touching the input. Use when asked to clean, transform, summarise, merge or convert CSV or TSV data, including spreadsheet exports with semicolons or European decimals.
compatibility: Requires Python 3; pandas is optional and used when installed. Works on files the agent can read locally.
metadata:
version: "1.0.0"
category: "Data Processing"
---
# CSV Data Processor
The agent works on local files; it does not upload data anywhere. The input file is never modified — results go to a new file whose name the user approves.
## Inputs to collect
- Path to the CSV file(s) and, for joins, the key columns.
- The operation in plain words: filter (column, operator, value), sort, select/rename columns, deduplicate on which keys, aggregate (group by + metric), join, pivot, or format conversion.
- Output path and format (CSV with UTF-8 by default, or XLSX/JSON/Parquet).
## Workflow
1. **Inspect before parsing.** Read the first bytes: try UTF-8 (strip a BOM with `utf-8-sig`); if decoding fails, report the byte offset and ask or try `cp1252`/`latin-1` (latin-1 never fails, so confirm accented characters look right). Detect the delimiter with `csv.Sniffer().sniff(sample, delimiters=',;\t|')` and the header with `has_header`. Report row count, columns and 5 sample rows.
2. **Types.** Decide numeric/date columns explicitly. For European exports use `pd.read_csv(path, sep=';', decimal=',', thousands='.')`. Keep identifiers (order IDs, ZIP codes, phone numbers) as strings so leading zeros survive: `dtype={'zip': 'string'}`. Parse dates with an explicit format when ambiguous (03/04 could be March or April).
3. **Operate.** Write the transformation as a short script so it can be re-run:
- filter `df[df.amount >= 100]`, sort `df.sort_values('amount', ascending=False)`
- dedupe `df.drop_duplicates(subset=['email'], keep='first')`
- aggregate `df.groupby('country', as_index=False).agg(total=('amount','sum'), orders=('order_id','count'))`
- join `left.merge(right, on='customer_id', how='left', validate='many_to_one')` (validate catches unexpected duplicates)
- without pandas, use `csv.DictReader`/`csv.DictWriter`, which handle quoted fields that contain the delimiter.
4. **Check.** Compare input vs output row counts and explain the difference (rows filtered, duplicates dropped, unmatched join rows). Spot-check a few rows by hand. Report nulls created by type conversion.
5. **Write** to the new path with `index=False` and `encoding='utf-8'` (use `utf-8-sig` if the file will be opened in Excel). Confirm before overwriting any existing file.
## Output format
- Detected settings: encoding, delimiter, header, row/column counts.
- The script or the exact operations applied.
- Row counts in/out with reasons, the output path, and a preview of the first rows.
## Limitations
- Files larger than memory need chunking (`pd.read_csv(..., chunksize=100_000)`) or a database/DuckDB.
- Formulas, merged cells and formatting from spreadsheets are not present in CSV.
- Do not paste rows containing personal data back into chat beyond what is needed for a preview.
## Example
Input file: `orders.csv`, ISO-8859-1, semicolon-separated, amounts like `1.234,50`, one customer named `"Smith; Jones"`.
Request: "Keep orders of 100 or more, largest first, save as UTF-8."
Good result: UTF-8 decoding fails at a byte offset, so the agent reports latin-1 and checks that `Müller` and `Åsa` render correctly. Delimiter `;`, header present, 5 rows. The quoted name with a semicolon is parsed as one field. 3 rows are written to `orders_over_100.csv` (2000.0, 1234.5, 450.0) and `orders.csv` is unchanged.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A finance export from a German ERP is ISO-8859-1, semicolon-separated, uses comma decimals, and needs filtering for a report.
orders.csv is an export from our ERP. Keep orders with amount 100 or more, sort largest first, and save it as a UTF-8 CSV.
Detected settings: UTF-8 decoding fails at a reported byte offset, so latin-1 is used after checking that names like Müller and Åsa display correctly. Delimiter ';' and a header row are detected; 5 rows and 5 columns. Read with decimal=',' and thousands='.', order_id kept as a string, and the quoted value "Smith; Jones" stays one field. Result: 3 of 5 rows kept (2000.0, 1234.5, 450.0), written to orders_over_100.csv in UTF-8 with no index column. The input file is unchanged and the script used is shown.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install CSV Data Processor by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts