# CSV Cleaner + Change Log (`torix33/csv-cleaner-change-log`) Actor

Free CSV/TSV cleaner by TORIX (AI-assisted). Trims whitespace, converts date columns to ISO YYYY-MM-DD, normalizes number columns, optional Title Case, drops empty rows/columns and duplicates. Outputs cleaned CSV, a before/after change log and an issues list. Review results before use.

- **URL**: https://apify.com/torix33/csv-cleaner-change-log.md
- **Developed by:** [Torix](https://apify.com/torix33) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CSV Cleaner: One Date Format, Numbers, Duplicates + Change Log

Turn a messy CSV into a clean one **and see exactly what was changed**. Paste the CSV or give a public link; you get:

- **Cleaned rows** (Dataset - export as CSV, Excel or JSON with the Apify Export button),
- **`CLEANED_CSV`** - the cleaned file with the same delimiter,
- **`CHANGE_LOG_CSV` / `CHANGE_LOG`** - a before/after list: record number, column, rule, old value, new value,
- **`ISSUES`** - values that could not be cleaned safely and were **left unchanged** (impossible dates, text in number columns),
- **`SUMMARY`** - counts: input rows, output rows, cell changes, removed empty rows and duplicates.

> Free test version. The Actor does not charge per result at the moment.

### How to run it in 3 steps

1. **Add your CSV.** Paste it into **CSV text** (the form is prefilled with made-up sample data) or put a direct public link in **Public link to a CSV file**.
2. **Press Start.** The prefilled sample finishes in a few seconds.
3. **Open the Output tab.** Check **Change log** and **Issues** first, then export the cleaned rows.

### What it does

| Rule | Example (before -> after) |
|---|---|
| Trim and collapse whitespace | `"  anna KOVAL "` -> `"anna KOVAL"` |
| Dates to ISO `YYYY-MM-DD` | `03/11/2026` -> `2026-11-03` (day first by default, switch with **dateOrder**); `5 Nov 2026`, `2026/11/3`, `03.11.26` also work |
| Numbers stored as numbers | `1 200,50`, `1,200.50`, `1.200,50`, `$12`, `(12.50)` -> `1200.5`, `1200.5`, `1200.5`, `12`, `-12.5` |
| Title Case for chosen columns | `anna KOVAL` -> `Anna Koval` |
| Remove empty rows and columns | `;;` rows and columns with no values |
| Remove duplicates **after** cleaning | `anna KOVAL;03/11/2026;1 200,50` and `Anna Koval;2026-11-03;1200.5` become the same row, the second is removed and logged |
| Header repair | empty names become `column_3`, repeated names become `name_2` |

Every removed row and every changed value is in the change log. Record numbers refer to the **input** file (header = record 1), so you can find the original line.

### What it will NOT do (on purpose)

- **No guessing.** A date that is impossible in the chosen order (`31.02.2026`, or `11/25/2026` when day-first) is reported in **Issues** and left as it was. Text in a number column is reported, not deleted.
- **No fuzzy matching.** Only rows that are identical after cleaning are removed. Typos such as `Kowal` vs `Kovalski` are not merged.
- **Identifier columns are protected.** Columns named like phone, zip, postal, id, sku, code, iban, nip, pesel are never turned into numbers automatically (leading zeros are kept). Values like `007` are never converted.
- **Ambiguous numbers:** a lone `1,200` is read as `1200`, a lone `1.200` as `1.2`. If your file uses the other convention, set **Decimal separator**.

### Input

```json
{
  "csvText": "name;date;amount\n  anna KOVAL ;03/11/2026;\"1 200,50\"\nAnna Koval;2026-11-03;1200.5\nOleh P.;31.02.2026;abc\n;;\nJan Nowak;15.11.2026;99,9",
  "titleCaseColumns": ["name"]
}
```

| Field | Meaning |
|---|---|
| `csvText` / `csvUrl` | Pasted CSV **or** a public direct link (http/https). Not both. |
| `delimiter` | `auto` (default), `comma`, `semicolon`, `tab`, `pipe` |
| `dateOrder` | `DMY` (default) or `MDY` |
| `decimalSeparator` | `auto` (default), `comma`, `dot` |
| `titleCaseColumns` | Columns written in Title Case |
| `dateColumns`, `numberColumns` | Optional: force the type of a column (otherwise detected when at least 60 % of the values fit) |
| `removeDuplicates`, `dedupeKey` | Remove duplicate rows; optionally compare only some columns (e.g. `email`) |
| `removeEmptyRows`, `removeEmptyColumns` | Both on by default |
| `maxRows` | Safety limit, default 100 000 |

### Output

Result of the sample above:

```csv
name;date;amount
Anna Koval;2026-11-03;1200.5
Oleh P.;31.02.2026;abc
Jan Nowak;2026-11-15;99.9
```

`CHANGE_LOG_CSV` (excerpt; rows in the real file are ordered by cleaning step, and whitespace trims are listed too):

```csv
record,column,rule,before,after
2,date,normalize_date,03/11/2026,2026-11-03
2,amount,normalize_number,"1 200,50",1200.5
2,name,title_case,anna KOVAL,Anna Koval
3,,remove_duplicate,Anna Koval | 2026-11-03 | 1200.5,removed - duplicate of record 2
5,,remove_empty_row,,removed - empty row
```

`ISSUES`:

```json
[
  { "record": 4, "column": "date", "value": "31.02.2026", "problem": "Not a valid date: not a real calendar date. Left unchanged." },
  { "record": 4, "column": "amount", "value": "abc", "problem": "Not a number (or an identifier with leading zeros). Left unchanged." }
]
```

### Excel users

The Actor reads **CSV/TSV text**, not `.xlsx` files. In Excel use *Save as -> CSV (UTF-8)*, then paste the text or upload the file to any place that gives a public direct link. After the run, use **Export -> Excel** on the Dataset to get an `.xlsx` back.

### Limitations

- CSV/TSV only (no `.xlsx`, no PDF, no scanned documents, no OCR).
- Public links only: links that need a login (private OneDrive, Google Drive, SharePoint) do not work. No cookies, no accounts, no secrets are used or needed.
- File size up to 20 MB. Encoding: UTF-8, or windows-1250 when the bytes are not valid UTF-8 (a note is shown).
- Dates with a time part (`2026-11-03 14:30`) are not converted and are reported in **Issues**.
- English month names only. Two-digit years: 00-69 = 2000s, 70-99 = 1900s.
- Check your data before you rely on it: the Actor applies fixed rules and shows every change, it does not know what your data means.

### Tips

- Run once, read the **Change log** and **Issues**, then adjust **dateOrder**, **decimalSeparator** or **titleCaseColumns** and run again.
- For a customer list, set **dedupeKey** to `email` to find the same person written in different ways.

### FAQ

**Is it free?** Yes, this is a free test version. If a paid version appears later, the price will be shown on this page before you use it.

**Who builds it?** TORIX, a small project that builds and maintains Actors with AI assistance. Feedback and problems are welcome in the Issues tab.

**Does it keep my data?** The input and results live only in your Apify run storage under your account.

# Actor input Schema

## `csvText` (type: `string`):

Paste the CSV here (first line = column names). Use this OR a public link below. The prefilled sample is made-up data.

## `csvUrl` (type: `string`):

Direct http(s) link to a .csv/.tsv file that anyone can open (no login). Private OneDrive/Google Drive links are not supported. Leave empty when you paste text above.

## `delimiter` (type: `string`):

Auto-detected from the first lines by default.

## `dateOrder` (type: `string`):

Dates are never guessed: a date that is impossible in this order is reported in the issues list instead of being swapped.

## `decimalSeparator` (type: `string`):

Auto reads 1 200,50 / 1,200.50 / 1.200,50 correctly. A lone 1,200 is read as 1200 and a lone 1.200 as 1.2 - set this option if your file differs.

## `titleCaseColumns` (type: `array`):

Column names (as in the header), e.g. name, city. Makes 'anna KOVAL' and 'Anna Koval' identical so duplicates are found.

## `dateColumns` (type: `array`):

Leave empty to detect date columns automatically.

## `numberColumns` (type: `array`):

Leave empty to detect number columns automatically. Phone, ZIP, ID, IBAN and similar columns are never converted automatically (leading zeros) - list them here only if you really want numbers.

## `removeDuplicates` (type: `boolean`):

Rows that are identical AFTER cleaning are removed (first one is kept). Typos are not matched - near-duplicates are not touched.

## `dedupeKey` (type: `array`):

Compare only these columns (e.g. email) instead of the whole row.

## `removeEmptyRows` (type: `boolean`):

Removes data rows in which every cell is empty or contains only whitespace. Each removal is listed in the change log. Turn off to keep such rows.

## `removeEmptyColumns` (type: `boolean`):

Removes columns that have no value in any data row (the header name alone does not count). Each removal is listed in the change log. Turn off to keep such columns.

## `maxRows` (type: `integer`):

Safety limit; the run stops with a message if the file has more rows.

## Actor input object example

```json
{
  "csvText": "name;date;amount\n  anna KOVAL ;03/11/2026;\"1 200,50\"\nAnna Koval;2026-11-03;1200.5\nOleh P.;31.02.2026;abc\n;;\nJan Nowak;15.11.2026;99,9",
  "delimiter": "auto",
  "dateOrder": "DMY",
  "decimalSeparator": "auto",
  "titleCaseColumns": [
    "name"
  ],
  "removeDuplicates": true,
  "removeEmptyRows": true,
  "removeEmptyColumns": true,
  "maxRows": 100000
}
```

# Actor output Schema

## `cleanedRows` (type: `string`):

No description

## `cleanedCsv` (type: `string`):

No description

## `changeLog` (type: `string`):

No description

## `issues` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "csvText": `name;date;amount
  anna KOVAL ;03/11/2026;"1 200,50"
Anna Koval;2026-11-03;1200.5
Oleh P.;31.02.2026;abc
;;
Jan Nowak;15.11.2026;99,9`,
    "titleCaseColumns": [
        "name"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("torix33/csv-cleaner-change-log").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "csvText": """name;date;amount
  anna KOVAL ;03/11/2026;\"1 200,50\"
Anna Koval;2026-11-03;1200.5
Oleh P.;31.02.2026;abc
;;
Jan Nowak;15.11.2026;99,9""",
    "titleCaseColumns": ["name"],
}

# Run the Actor and wait for it to finish
run = client.actor("torix33/csv-cleaner-change-log").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "csvText": "name;date;amount\\n  anna KOVAL ;03/11/2026;\\"1 200,50\\"\\nAnna Koval;2026-11-03;1200.5\\nOleh P.;31.02.2026;abc\\n;;\\nJan Nowak;15.11.2026;99,9",
  "titleCaseColumns": [
    "name"
  ]
}' |
apify call torix33/csv-cleaner-change-log --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,torix33/csv-cleaner-change-log"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/JbbpQDGuet2S7GugZ/builds/wMCrYe9dWhGZUMJo9/openapi.json
