# CSV Dedupe & Normalizer (`toned_orbweaver/csv-dedupe-normalizer`) Actor

Clean messy CSV contact/lead lists: trim, normalize emails, phones (E.164), names, and remove duplicates. No scraping.

- **URL**: https://apify.com/toned_orbweaver/csv-dedupe-normalizer.md
- **Developed by:** [Bonnie & Tim](https://apify.com/toned_orbweaver) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.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 Dedupe & Normalizer

Clean up messy **contact and lead lists** in seconds. Give it a CSV (paste it or link to it) and get back a tidy, **deduplicated** list with normalized emails, **E.164 phone numbers**, properly capitalized names, and a flag on every row that needs attention. No scraping and no browser: it only processes the data you provide.

### What can it do?

- ✉️ **Normalize emails**: trims, lowercases, and merges Gmail variants (`John.Smith+news@Gmail.com` → `johnsmith@gmail.com`)
- 📞 **Normalize phones to E.164**: `(312) 555-0199` → `+13125550199`, with a configurable default country code
- 🔤 **Title-case names**: `jOHN smith` → `John Smith`
- 🧹 **Remove duplicates** on the columns you choose, compared *after* normalization so near-duplicates are caught
- 🚩 **Flag problems**: invalid emails and phones are marked in a `_flags` column, or rows with bad emails can be dropped
- 📁 **Download a cleaned CSV** plus a stats summary, or export the dataset to Excel, JSON, or CSV

### Who is it for?

- **Sales and marketing teams** cleaning lead lists before importing them into a CRM or email tool
- **Event organizers** merging sign-up sheets from different sources
- **Agencies and freelancers** preparing client contact data
- Anyone tired of fixing spreadsheets by hand

### How to use it

1. Paste your CSV into **CSV text**, or put a public link to a CSV file in **CSV URL**. The first row must contain the column headers.
2. Tell the Actor which columns hold **emails**, **phones**, and **names** (defaults: `email` and `phone`).
3. Choose the **Dedupe on columns**, for example `email`. Leave it empty to remove only rows that are identical.
4. Click **Start**. Results appear in the **Output** tab, and the cleaned file is saved as `CLEANED_CSV`.

If you start the Actor with no CSV at all, it cleans a small built-in demo list so you can see how it works.

### Input example

```json
{
  "csvText": "name,email,phone\njOHN smith,John.Smith+news@Gmail.com,(312) 555-0199\nJohn Smith,johnsmith@gmail.com,312.555.0199\nana LEE,ana.lee@example.org,+44 20 7946 0958\nRaj Patel,raj.patel@example,555-0142\n",
  "dedupeColumns": ["email"],
  "emailColumns": ["email"],
  "phoneColumns": ["phone"],
  "nameColumns": ["name"],
  "defaultCountryCode": "1",
  "dropInvalidEmails": false
}
```

### Output example

One dataset row per cleaned contact. All original columns are kept, and `_flags` lists any problems:

```json
[
  { "name": "John Smith", "email": "johnsmith@gmail.com", "phone": "+13125550199", "_flags": "" },
  { "name": "Ana Lee", "email": "ana.lee@example.org", "phone": "+442079460958", "_flags": "" },
  { "name": "Raj Patel", "email": "raj.patel@example", "phone": "+15550142", "_flags": "invalid_email:email;invalid_phone:phone" }
]
```

The key-value store also contains:

- `CLEANED_CSV`: the cleaned list as a ready-to-import CSV file
- `STATS`: a summary such as `{"rowsIn": 4, "duplicates": 1, "dropped": 0, "rowsOut": 3}`

### How much does it cost?

Very little. The Actor runs with 256 MB of memory and no proxy or browser, so cleaning thousands of rows takes seconds and a tiny fraction of a compute unit. See the **Pricing** tab for the current price.

### Tips and limits

- Files should be UTF-8. Excel users can choose **Save As → CSV UTF-8**.
- Phone formatting is rule-based. Numbers without a `+` prefix use the **Default country calling code** (1 = US/Canada, 44 = UK, 61 = Australia, and so on).
- Gmail dots and `+tags` are removed because Gmail ignores them. Other providers are only lowercased.
- Cells beyond the header columns are kept in an `_extra` column instead of being lost.

### Your data

The Actor only processes the data you send it for the duration of the run. Results stay in your own Apify storage under Apify's normal retention rules. Make sure you have the right to process the personal data in your lists.

### Feedback

Need another normalization rule or column type? Open an issue on the **Issues** tab.

# Actor input Schema

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

Paste CSV content directly (first row = headers). If both CSV text and CSV URL are empty, a small demo list is cleaned.

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

Public URL of a CSV file (UTF-8, first row = headers). Used when CSV text is empty.

## `dedupeColumns` (type: `array`):

Columns that form the duplicate key (compared after normalization). Leave empty to compare whole rows.

## `emailColumns` (type: `array`):

Column names treated as emails (lowercased and validated).

## `phoneColumns` (type: `array`):

Column names treated as phones (normalized toward E.164).

## `nameColumns` (type: `array`):

Column names Title-Cased for people/org names.

## `defaultCountryCode` (type: `string`):

Calling-code digits used when a phone has no country prefix (default 1 = US/CA).

## `dropInvalidEmails` (type: `boolean`):

If true, drop rows whose email columns fail basic validation.

## Actor input object example

```json
{
  "csvText": "name,email,phone\njOHN smith,John.Smith+news@Gmail.com,(312) 555-0199\nJohn Smith,johnsmith@gmail.com,312.555.0199\nana LEE,ana.lee@example.org,+44 20 7946 0958\nRaj Patel,raj.patel@example,555-0142\n",
  "dedupeColumns": [
    "email"
  ],
  "emailColumns": [
    "email"
  ],
  "phoneColumns": [
    "phone"
  ],
  "nameColumns": [
    "name"
  ],
  "defaultCountryCode": "1",
  "dropInvalidEmails": false
}
```

# Actor output Schema

## `results` (type: `string`):

Normalized, deduplicated CSV rows.

## `files` (type: `string`):

Key-value store with CLEANED_CSV (text/csv) and STATS (JSON).

# 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,email,phone
jOHN smith,John.Smith+news@Gmail.com,(312) 555-0199
John Smith,johnsmith@gmail.com,312.555.0199
ana LEE,ana.lee@example.org,+44 20 7946 0958
Raj Patel,raj.patel@example,555-0142`,
    "dedupeColumns": [
        "email"
    ],
    "nameColumns": [
        "name"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("toned_orbweaver/csv-dedupe-normalizer").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,email,phone
jOHN smith,John.Smith+news@Gmail.com,(312) 555-0199
John Smith,johnsmith@gmail.com,312.555.0199
ana LEE,ana.lee@example.org,+44 20 7946 0958
Raj Patel,raj.patel@example,555-0142
""",
    "dedupeColumns": ["email"],
    "nameColumns": ["name"],
}

# Run the Actor and wait for it to finish
run = client.actor("toned_orbweaver/csv-dedupe-normalizer").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,email,phone\\njOHN smith,John.Smith+news@Gmail.com,(312) 555-0199\\nJohn Smith,johnsmith@gmail.com,312.555.0199\\nana LEE,ana.lee@example.org,+44 20 7946 0958\\nRaj Patel,raj.patel@example,555-0142\\n",
  "dedupeColumns": [
    "email"
  ],
  "nameColumns": [
    "name"
  ]
}' |
apify call toned_orbweaver/csv-dedupe-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toned_orbweaver/csv-dedupe-normalizer"
        }
    }
}
```

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/MXoKXZy3TR2h8Gpz3/builds/vkgG4nf3vE6C3nTCM/openapi.json
