# Dataset Cleaner: dedupe, normalize phones, emails and URLs (`opstoolkit/dataset-cleaner`) Actor

Clean scraper, CSV or JSON rows: remove duplicates (exact, loose, fuzzy), normalize phones to E.164, emails, URLs, domains, dates and countries, split names, drop empty columns. Reads a dataset ID, file link or pasted rows. No AI. $0.0003 per row written.

- **URL**: https://apify.com/opstoolkit/dataset-cleaner.md
- **Developed by:** [Elio Saliba](https://apify.com/opstoolkit) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 row outputs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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

## Dataset Cleaner: dedupe, normalize phones, emails and URLs

Give it a scraper dataset, a CSV or JSON link, or pasted rows, and get clean rows back: duplicates removed, phones written as E.164, emails, URLs and domains normalized, dates in ISO format, countries as ISO codes, full names split, empty columns dropped and columns renamed or selected as you choose.

It is plain code. No AI, no calls to other services, and no data leaves the run. Rows go in, clean rows come out, the same way every time.

Built for people who scrape or buy lists and then spend an hour in a spreadsheet: lead-gen agencies, e-commerce teams merging several stores, data teams preparing a CRM import, and n8n or Make users who want one clean step between a scraper and a sheet.

**$0.0003 per row written ($0.30 per 1,000).** Duplicates, empty rows and rows you filter out are free. No fee per file. Apify's free monthly credit covers a first test run.

### What you get

One row per surviving input row, with your own columns, cleaned, plus the columns your rules add next to the one they came from.

| Operation | Example in | Example out |
|---|---|---|
| `phone` | `(512) 677-7667` | `+15126777667`, `phoneValid: true`, `phoneCountry: "US"`, `phoneType: "fixed_or_mobile"` |
| `email` | `Jane <Jane@ACME.com>` | `jane@acme.com`, `emailValid: true` |
| `url` | `HTTP://www.Acme.com/?utm_source=x` | `http://acme.com` |
| `domain` | `https://blog.acme.co.uk/post` | `acme.co.uk` |
| `date` | `March 5, 2024`, `05/03/2024`, `1709649000` | `2024-03-05`, `2024-05-03`, `2024-03-05T14:30:00Z` |
| `country` | `lebanon`, `LBN`, `USA` | `LB`, `LB`, `US` |
| `money` | `1.234,50 €` | `1234.5`, `priceCurrency: "EUR"` |
| `split-name` | `SMITH, JOHN Q` | `firstName: "John"`, `middleName: "Q"`, `lastName: "Smith"` |
| `title` | `BLUE DOOR BAKERY` | `Blue Door Bakery` (mixed-case text such as `iPhone` is left alone) |

Besides the dataset, the run writes a `SUMMARY` record (rows read and written, duplicates dropped, invalid phones, emails, URLs and dates) and, if you ask for it, a `cleaned.csv` file in the key-value store. The record holds counts and no row data.

### How to use

1. **Point it at your data.** Paste rows, add one or more Apify dataset IDs (from the Storage tab of any run), or add links to CSV, JSON or JSONL files. You can mix them. Rows are read in that order and cleaned as one list.
2. **Write rules**, one per line: `column: operation option=value`. For example `phone: phone country=LB`.
3. **Pick duplicate columns** and how strict to be. Press Start.

The default input is a small made-up list of 13 rows with duplicate companies, mixed phone formats, URLs with tracking parameters and country names in different forms. It finishes in seconds and shows every operation.

### Use it from an AI agent

In Claude, ChatGPT or Cursor, add the Apify MCP server (https://mcp.apify.com) and ask the agent to run this Actor on a dataset ID or a file link. The agent writes the `rules` lines and the `dedupeBy` columns from your sentence.

Example prompt: "Use the Apify Actor opstoolkit/dataset-cleaner on dataset aBcDeFgHiJkLmNoPq: normalize phones to E.164 for Lebanon, remove duplicates by phone or email, keep the most complete row and give me a CSV."

### Rules

One rule per line. `*` as the column applies the rule to every column. A comma lists several columns. Rules run in the order you write them, after whitespace trimming.

```
*: trim
company: title
contact: split-name
phone: phone country=LB
email: email
website: domain into=domain
website: url
country: country
added: date dayfirst=yes
```

| Operation | Options |
|---|---|
| `trim`, `collapse-spaces` | Trim and collapse spaces (also done for you by "Trim whitespace") |
| `lower`, `upper`, `strip-accents`, `strip-html` | Plain text changes. `strip-html` removes tags and decodes `&amp;` |
| `title` | `force=yes` also re-cases mixed-case text |
| `phone` | `country=XX` (ISO code), `format=e164` (default), `international` or `national`, `extras=no` to skip the extra columns |
| `email` | `extras=no` |
| `url` | `strip-query=yes`, `keep-www=yes`, `scheme=https` to force https |
| `domain` | Registered domain, public-suffix aware: `blog.acme.co.uk` gives `acme.co.uk` |
| `host` | Full host name without `www` |
| `date` | `dayfirst=yes` for 31/12/2024 style, `time=drop` for dates only |
| `country` | `to=alpha2` (default), `alpha3` or `name` |
| `money` | `currency=USD` when none is written, `decimal=comma` or `dot` for numbers like `1.234` |
| `split-name` | Writes `firstName`, `middleName`, `lastName`. Handles Dr., Jr., `Last, First` and van, de, bin |
| `drop` | Removes the column |

Options for every operation except `drop` and `split-name`:

- `into=newcolumn` keeps the original column and writes the result to another one.
- `invalid=blank` empties values that could not be read. The default keeps the original text so you can see what failed. Combine with "Drop rows missing these columns" to remove rows with a bad phone or email.

A rule on a list value, such as the `emails` or `phones` arrays from company-contact-finder, is applied to every item, and repeated items are merged.

### Duplicates

Set `dedupeBy` to the columns that identify a record, for example `phone` and `email`.

| Mode | What counts as the same |
|---|---|
| `exact` | Identical after trimming. Case counts |
| `loose` (default) | Ignores case, accents, punctuation, spacing, `www`, `http`, tracking parameters, phone formatting and company endings such as Inc, Ltd, GmbH, SARL |
| `fuzzy` | Loose, plus close spellings above the similarity you set (default 90 of 100) |

`dedupeMatch` decides whether every listed column has to match (`all`) or one is enough (`any`). `any` is the usual choice for leads: the same phone or the same email means the same business. Choose which row to keep: `first`, `last` or `most-complete` (the row with the most filled columns).

Rows where all the duplicate columns are empty are never treated as duplicates. Phones are compared as E.164 when the number can be read, so `(512) 677-7667` and `+1 512 677 7667` match. Fuzzy mode compares values that start with the same three letters, so a typo in the first letters is not caught.

### Input example

```json
{
  "datasetIds": ["YOUR_DATASET_ID"],
  "defaultCountry": "LB",
  "rules": [
    "*: trim",
    "company: title",
    "phone: phone country=LB",
    "email: email invalid=blank",
    "website: domain into=domain",
    "website: url"
  ],
  "dedupeBy": ["phone", "email", "domain"],
  "dedupeMatch": "any",
  "keep": "most-complete",
  "requiredFields": ["phone"],
  "dropEmptyColumns": true,
  "exportCsv": true
}
```

### Output example

```json
{
  "company": "Blue Door Bakery",
  "contact": "MARIA KHOURY",
  "firstName": "Maria",
  "lastName": "Khoury",
  "phone": "+9613123456",
  "phoneValid": true,
  "phoneCountry": "LB",
  "phoneType": "mobile",
  "email": "maria@bluedoor.lb",
  "emailValid": true,
  "website": "https://bluedoor.lb",
  "domain": "bluedoor.lb",
  "country": "LB",
  "added": "2024-03-04"
}
```

The `SUMMARY` record for the same run:

```json
{
  "rowsRead": 13, "rowsWritten": 7, "duplicatesDropped": 5, "emptyRowsDropped": 1,
  "invalid": {"phones": 1, "emails": 1},
  "chargedRows": 7, "stoppedAtMaxCost": false
}
```

### Pricing

Pay per event: **$0.30 per 1,000 rows written** ($0.0003 each). Apify adds a small fee for each run start.

| Rows written | Cost |
|---|---|
| 1,000 | $0.30 |
| 10,000 | $3 |
| 100,000 | $30 |

You pay only for rows that reach the output. Duplicates, empty rows and rows dropped by "Drop rows missing these columns" are free, and so is reading a dataset or file. Set a max cost per run in the Apify run options to cap spending. When the run reaches it, it stops, and `SUMMARY.notReturnedMaxCostReached` says how many rows were left out.

### Works well with

- **[Local Business Leads](https://apify.com/opstoolkit/local-business-leads)** and **[Company Contact Finder](https://apify.com/opstoolkit/company-contact-finder)**: pass the dataset ID of a finished run as `datasetIds`. Clean `phone` and `website`, merge several cities or runs into one list, and dedupe on `domain`, `phone` and `email`. The `emails` and `phones` of Company Contact Finder are lists, and rules work on each item.
- **[Email Validator](https://apify.com/opstoolkit/email-syntax-mx-validator)**: copy the cleaned `email` column into its `emails` list to check DNS and disposable domains.
- **[Phone Number Validator](https://apify.com/opstoolkit/phone-number-validator)**: the same check for phones. Give it the cleaned `phone` column to get valid or not, line type (mobile, fixed, VoIP), carrier, area and time zones per number, or call it as an API for one number at a time.
- **[Domain Rank Lookup](https://apify.com/opstoolkit/domain-rank-lookup)**: use `website: domain into=domain` here, then give the cleaned dataset ID to Domain Rank Lookup with the field `domain` to sort the list by site strength.
- **[ATS Jobs Feed](https://apify.com/opstoolkit/ats-jobs-feed)**: merge the jobs from several runs or boards, drop repeats with `dedupeBy` on `url`, and keep only the columns you need with `selectFields`.

A typical chain: Local Business Leads for a city, Company Contact Finder on the websites, this Actor with `dedupeBy` on `domain`, `phone` and `email`, Email Validator, then Domain Rank Lookup. Use an Apify webhook or an integration (Zapier, Make, n8n) to start each step when the previous one finishes.

### Limits

- **Phone validity is a numbering-plan check.** `phoneValid: true` means the number fits that country's rules for length and prefix, from the libphonenumber data bundled in the Actor. It does not tell you the line is active or who owns it. Numbers without a `+` need a country (`defaultCountry` or `country=XX`).
- **Phone type is a guess for some countries.** US numbers come back as `fixed_or_mobile` because the numbering plan does not separate them.
- **Dates like 03/04/2024 are ambiguous.** The default reads month first. Use `dayfirst=yes` for day first. Dates with only a year or a year and month come back as `2024` or `2024-03`.
- **Names are split by common rules.** Western and Arabic-style names with particles work. Single names get a first name only. Check unusual names.
- **Country matching covers ISO names, codes and common spellings.** Anything else is left as written and counted in `SUMMARY.invalid.countriesNotMatched`.
- **Memory.** Plain runs stream rows and keep only the duplicate keys in memory. Keeping the last or most complete duplicate, dropping empty columns and the CSV file hold the rows too: about 1 GB for 200,000 rows. The default is 256 MB. Raise the run memory for bigger lists. `maxRows` (default 200,000, up to 2 million) stops the read.
- **Files** must be public CSV, JSON or JSONL links, up to 60 MB each. Excel files are not read; save them as CSV. Links to private network addresses are refused.
- **Fuzzy mode** compares each value with earlier values that start with the same three letters. It is fast on large lists and misses typos in the first three letters.
- You are responsible for having a legal basis to process the data you give it. The Actor does not look anyone up and keeps nothing after the run, except the dataset and files in your own account.

### Integrations

Everything Apify supports works here: schedules, webhooks, the REST API, and the official integrations with Zapier, Make, n8n and Google Sheets. The **API** tab has ready code for JavaScript, Python and cURL.

### FAQ

**Does it use AI?**
No. Every step is a fixed rule, so the same input always gives the same output, and the price per row does not depend on a model.

**Can it merge two datasets?**
Add both IDs to `datasetIds`. They are cleaned as one list, and duplicates across them are removed. Set `sourceColumn` to see which row came from where.

**Why was a row dropped?**
It was empty, it was a duplicate of an earlier row, or it was missing a column from "Drop rows missing these columns". The `SUMMARY` record counts each kind.

**Why did my phone stay as typed?**
It could not be read as a valid number for the country. Add `country=XX` to the rule or set the default country. The raw text is kept unless you use `invalid=blank`.

**Something broke.**
Open an issue on the Issues tab with the run link. I reply within a day.

# Actor input Schema

## `rows` (type: `array`):

Rows to clean, as a JSON list of objects. Example: \[{"company": "ACME inc", "phone": "03 123 456", "email": "Info@Acme.com"}]. Leave empty when you use datasetIds or fileUrls. Inline rows are read first, then datasets, then files, and all are cleaned as one list. The prefilled sample is messy on purpose: mixed phone formats, duplicate companies, tracking parameters in URLs and country names in different forms.

## `datasetIds` (type: `array`):

IDs of Apify datasets your account can read, one per item. Example: \["aBcDeFgHiJkLmNoPq"]. Typical use: the default dataset of a finished run of Local Business Leads or Company Contact Finder, found in the run's Storage tab. Several IDs are merged into one list, and duplicates across them are removed.

## `fileUrls` (type: `array`):

Public links, one per item. Example: \["https://example.com/leads.csv"]. The first row of a CSV is the header. Up to 60 MB per file. Excel files are not read, save them as CSV. Links to private network addresses are refused.

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

Reading stops after this many rows in total. A whole number from 1 to 2,000,000. Rows are held in memory only when you keep the last or most complete duplicate, drop empty columns or write the CSV: about 1 GB of run memory covers 200,000 rows then. Default: 200000.

## `trimWhitespace` (type: `boolean`):

When true, every text value is trimmed, repeated spaces are collapsed and non-breaking spaces become normal ones. Column names are trimmed too. Default: true.

## `placeholdersAsEmpty` (type: `boolean`):

When true, values that are only N/A, null, undefined, nan, none or a dash become empty (null), so they count as missing in duplicate checks and required columns. Default: true.

## `flattenObjects` (type: `boolean`):

When true, {"address": {"city": "Beirut"}} becomes a column called address.city. Lists are kept as lists. Do this before rules that need a flat column name. Default: false.

## `rules` (type: `array`):

Cleaning rules, one per item, written as column: operation option=value. Operations: trim, collapse-spaces, lower, upper, title, strip-accents, strip-html, phone, email, url, domain, host, date, country, money, split-name, drop. Example: \["phone: phone country=LB", "website: domain into=domain", "added: date dayfirst=yes"]. Use \* as the column for every column, commas to list several columns, into=newcolumn to keep the original, invalid=blank to empty unreadable values. Rules run in the order given.

## `defaultCountry` (type: `string`):

Two-letter ISO country code, for example LB, US or GB. Used to read phone numbers written without a + sign and to match phones when deduplicating. A rule can override it with country=XX. Leave empty if all numbers already start with + and a country code.

## `dedupeBy` (type: `array`):

Column names that identify one record, as they are after your rules ran. Example: \["phone", "email"]. Leave empty to keep every row. Rows where all of these columns are empty are never treated as duplicates. Duplicates are dropped and not charged.

## `dedupeMode` (type: `string`):

exact: values must be identical after trimming, case counts. loose: ignores case, accents, punctuation, spacing, www, http, tracking parameters, phone formatting and company endings such as Inc or Ltd. fuzzy: loose, plus close spellings above fuzzyThreshold. Default: loose.

## `dedupeMatch` (type: `string`):

all: every column in dedupeBy must match for two rows to be duplicates. any: one matching column is enough, for example the same phone or the same email, which is the usual choice for leads. Default: all.

## `fuzzyThreshold` (type: `integer`):

Only used when dedupeMode is fuzzy. A whole number from 50 to 100, higher is stricter. 90 catches typos and small wording changes. Only values that start with the same three letters are compared. Default: 90.

## `keep` (type: `string`):

first: the earliest row. last: the latest row. most-complete: the row with the most filled columns. Anything but first holds all rows in memory until the end. Default: first.

## `requiredFields` (type: `array`):

Column names, one per item. Example: \["phone"]. A row is dropped, and not charged, when any of these columns is empty after your rules ran. Combine with invalid=blank on a rule to drop rows with a bad phone or email. Leave empty to keep rows whatever they lack.

## `dropEmptyColumns` (type: `boolean`):

When true, a column with no value in any row is left out of the output. Holds all rows in memory until the end. Default: false.

## `renameFields` (type: `object`):

Object mapping old column name to new name. Example: {"company": "Business name"}. Applied last, after duplicates are found, so dedupeBy and rules use the old names.

## `selectFields` (type: `array`):

Column names to keep, in output order, one per item. Example: \["businessName", "phone", "email"]. Use the names after renaming. Leave empty to keep all columns. A name that does not exist gives an empty column.

## `sourceColumn` (type: `string`):

Optional. A column name such as source. When set, each row gets a column with where it came from: inline, the dataset ID or the file link. Useful when you merge several sources. Leave empty to add no column.

## `exportCsv` (type: `boolean`):

When true, the cleaned rows are also saved as cleaned.csv in the run's key-value store. Lists are joined with semicolons. Holds the written rows in memory. Default: false.

## Actor input object example

```json
{
  "rows": [
    {
      "company": "Blue Door Bakery",
      "contact": "MARIA KHOURY",
      "phone": "03 123 456",
      "email": "Maria@BlueDoor.lb",
      "website": "www.bluedoor.lb/",
      "country": "lebanon",
      "added": "03/04/2024"
    },
    {
      "company": "Blue Door Bakery",
      "contact": "Khoury, Maria",
      "phone": "+961 3 123 456",
      "email": "maria@bluedoor.lb",
      "website": "https://bluedoor.lb",
      "country": "LB",
      "added": "2024-04-03"
    },
    {
      "company": "Cedar & Sons Ltd",
      "contact": "john smith jr",
      "phone": "+1 512 677 7667",
      "email": "orders@cedarsons.com",
      "website": "HTTP://CedarSons.com/?utm_source=newsletter",
      "country": "United States",
      "added": "March 5, 2024"
    },
    {
      "company": "CEDAR & SONS",
      "contact": "",
      "phone": "+1 (512) 677-7667",
      "email": "",
      "website": "cedarsons.com",
      "country": "USA",
      "added": ""
    },
    {
      "company": "Atlas Plumbing",
      "contact": "Dr. Rami Haddad",
      "phone": "71 555 888",
      "email": "",
      "website": "atlasplumbing.com.lb",
      "country": "Lebanon",
      "added": "12 Jan 2024"
    },
    {
      "company": "Atlas Plumbing SARL",
      "contact": "",
      "phone": "71555888",
      "email": "info@atlasplumbing.com.lb",
      "website": "",
      "country": "LB",
      "added": "N/A"
    },
    {
      "company": "Nile Dental Clinic",
      "contact": "Dr. Amira Hassan",
      "phone": "+20 100 123 4567",
      "email": "contact@niledental.eg",
      "website": "niledental.eg",
      "country": "Egypt",
      "added": "2024-01-12"
    },
    {
      "company": "Berlin Bike Shop GmbH",
      "contact": "Anna MÜLLER",
      "phone": "+49 30 901820",
      "email": "N/A",
      "website": "https://www.berlinbike.de/shop",
      "country": "Germany",
      "added": "2024-02-29"
    },
    {
      "company": "berlin bike shop",
      "contact": "",
      "phone": "+49 30 901820",
      "email": "info@berlinbike.de",
      "website": "berlinbike.de",
      "country": "DE",
      "added": ""
    },
    {
      "company": "Cafe Beirut",
      "contact": "",
      "phone": "not a number",
      "email": "hello@cafebeirut",
      "website": "cafebeirut.com",
      "country": "Lebanon",
      "added": "n/a"
    },
    {
      "company": "Sunrise Yoga",
      "contact": "Priya Patel",
      "phone": "+91 98765 43210",
      "email": "priya@sunriseyoga.in",
      "website": "sunriseyoga.in/",
      "country": "india",
      "added": "05/03/2024"
    },
    {
      "company": "",
      "contact": "",
      "phone": "",
      "email": "",
      "website": "",
      "country": "",
      "added": ""
    },
    {
      "company": "Sunrise Yoga Studio",
      "contact": "PRIYA PATEL",
      "phone": "",
      "email": "PRIYA@sunriseyoga.in",
      "website": "www.sunriseyoga.in",
      "country": "IN",
      "added": ""
    }
  ],
  "maxRows": 200000,
  "trimWhitespace": true,
  "placeholdersAsEmpty": true,
  "flattenObjects": false,
  "rules": [
    "*: trim",
    "company: title",
    "contact: split-name",
    "phone: phone country=LB",
    "email: email",
    "website: domain into=domain",
    "website: url",
    "country: country",
    "added: date"
  ],
  "defaultCountry": "LB",
  "dedupeBy": [
    "phone",
    "email"
  ],
  "dedupeMode": "loose",
  "dedupeMatch": "any",
  "fuzzyThreshold": 90,
  "keep": "most-complete",
  "dropEmptyColumns": true,
  "renameFields": {
    "company": "businessName"
  },
  "exportCsv": true
}
```

# Actor output Schema

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

No description

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

No description

## `csv` (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 = {
    "rows": [
        {
            "company": "Blue Door Bakery",
            "contact": "MARIA KHOURY",
            "phone": "03 123 456",
            "email": "Maria@BlueDoor.lb",
            "website": "www.bluedoor.lb/",
            "country": "lebanon",
            "added": "03/04/2024"
        },
        {
            "company": "Blue Door Bakery",
            "contact": "Khoury, Maria",
            "phone": "+961 3 123 456",
            "email": "maria@bluedoor.lb",
            "website": "https://bluedoor.lb",
            "country": "LB",
            "added": "2024-04-03"
        },
        {
            "company": "Cedar & Sons Ltd",
            "contact": "john smith jr",
            "phone": "+1 512 677 7667",
            "email": "orders@cedarsons.com",
            "website": "HTTP://CedarSons.com/?utm_source=newsletter",
            "country": "United States",
            "added": "March 5, 2024"
        },
        {
            "company": "CEDAR & SONS",
            "contact": "",
            "phone": "+1 (512) 677-7667",
            "email": "",
            "website": "cedarsons.com",
            "country": "USA",
            "added": ""
        },
        {
            "company": "Atlas Plumbing",
            "contact": "Dr. Rami Haddad",
            "phone": "71 555 888",
            "email": "",
            "website": "atlasplumbing.com.lb",
            "country": "Lebanon",
            "added": "12 Jan 2024"
        },
        {
            "company": "Atlas Plumbing SARL",
            "contact": "",
            "phone": "71555888",
            "email": "info@atlasplumbing.com.lb",
            "website": "",
            "country": "LB",
            "added": "N/A"
        },
        {
            "company": "Nile Dental Clinic",
            "contact": "Dr. Amira Hassan",
            "phone": "+20 100 123 4567",
            "email": "contact@niledental.eg",
            "website": "niledental.eg",
            "country": "Egypt",
            "added": "2024-01-12"
        },
        {
            "company": "Berlin Bike Shop GmbH",
            "contact": "Anna MÜLLER",
            "phone": "+49 30 901820",
            "email": "N/A",
            "website": "https://www.berlinbike.de/shop",
            "country": "Germany",
            "added": "2024-02-29"
        },
        {
            "company": "berlin bike shop",
            "contact": "",
            "phone": "+49 30 901820",
            "email": "info@berlinbike.de",
            "website": "berlinbike.de",
            "country": "DE",
            "added": ""
        },
        {
            "company": "Cafe Beirut",
            "contact": "",
            "phone": "not a number",
            "email": "hello@cafebeirut",
            "website": "cafebeirut.com",
            "country": "Lebanon",
            "added": "n/a"
        },
        {
            "company": "Sunrise Yoga",
            "contact": "Priya Patel",
            "phone": "+91 98765 43210",
            "email": "priya@sunriseyoga.in",
            "website": "sunriseyoga.in/",
            "country": "india",
            "added": "05/03/2024"
        },
        {
            "company": "",
            "contact": "",
            "phone": "",
            "email": "",
            "website": "",
            "country": "",
            "added": ""
        },
        {
            "company": "Sunrise Yoga Studio",
            "contact": "PRIYA PATEL",
            "phone": "",
            "email": "PRIYA@sunriseyoga.in",
            "website": "www.sunriseyoga.in",
            "country": "IN",
            "added": ""
        }
    ],
    "rules": [
        "*: trim",
        "company: title",
        "contact: split-name",
        "phone: phone country=LB",
        "email: email",
        "website: domain into=domain",
        "website: url",
        "country: country",
        "added: date"
    ],
    "defaultCountry": "LB",
    "dedupeBy": [
        "phone",
        "email"
    ],
    "dedupeMatch": "any",
    "keep": "most-complete",
    "dropEmptyColumns": true,
    "renameFields": {
        "company": "businessName"
    },
    "exportCsv": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("opstoolkit/dataset-cleaner").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 = {
    "rows": [
        {
            "company": "Blue Door Bakery",
            "contact": "MARIA KHOURY",
            "phone": "03 123 456",
            "email": "Maria@BlueDoor.lb",
            "website": "www.bluedoor.lb/",
            "country": "lebanon",
            "added": "03/04/2024",
        },
        {
            "company": "Blue Door Bakery",
            "contact": "Khoury, Maria",
            "phone": "+961 3 123 456",
            "email": "maria@bluedoor.lb",
            "website": "https://bluedoor.lb",
            "country": "LB",
            "added": "2024-04-03",
        },
        {
            "company": "Cedar & Sons Ltd",
            "contact": "john smith jr",
            "phone": "+1 512 677 7667",
            "email": "orders@cedarsons.com",
            "website": "HTTP://CedarSons.com/?utm_source=newsletter",
            "country": "United States",
            "added": "March 5, 2024",
        },
        {
            "company": "CEDAR & SONS",
            "contact": "",
            "phone": "+1 (512) 677-7667",
            "email": "",
            "website": "cedarsons.com",
            "country": "USA",
            "added": "",
        },
        {
            "company": "Atlas Plumbing",
            "contact": "Dr. Rami Haddad",
            "phone": "71 555 888",
            "email": "",
            "website": "atlasplumbing.com.lb",
            "country": "Lebanon",
            "added": "12 Jan 2024",
        },
        {
            "company": "Atlas Plumbing SARL",
            "contact": "",
            "phone": "71555888",
            "email": "info@atlasplumbing.com.lb",
            "website": "",
            "country": "LB",
            "added": "N/A",
        },
        {
            "company": "Nile Dental Clinic",
            "contact": "Dr. Amira Hassan",
            "phone": "+20 100 123 4567",
            "email": "contact@niledental.eg",
            "website": "niledental.eg",
            "country": "Egypt",
            "added": "2024-01-12",
        },
        {
            "company": "Berlin Bike Shop GmbH",
            "contact": "Anna MÜLLER",
            "phone": "+49 30 901820",
            "email": "N/A",
            "website": "https://www.berlinbike.de/shop",
            "country": "Germany",
            "added": "2024-02-29",
        },
        {
            "company": "berlin bike shop",
            "contact": "",
            "phone": "+49 30 901820",
            "email": "info@berlinbike.de",
            "website": "berlinbike.de",
            "country": "DE",
            "added": "",
        },
        {
            "company": "Cafe Beirut",
            "contact": "",
            "phone": "not a number",
            "email": "hello@cafebeirut",
            "website": "cafebeirut.com",
            "country": "Lebanon",
            "added": "n/a",
        },
        {
            "company": "Sunrise Yoga",
            "contact": "Priya Patel",
            "phone": "+91 98765 43210",
            "email": "priya@sunriseyoga.in",
            "website": "sunriseyoga.in/",
            "country": "india",
            "added": "05/03/2024",
        },
        {
            "company": "",
            "contact": "",
            "phone": "",
            "email": "",
            "website": "",
            "country": "",
            "added": "",
        },
        {
            "company": "Sunrise Yoga Studio",
            "contact": "PRIYA PATEL",
            "phone": "",
            "email": "PRIYA@sunriseyoga.in",
            "website": "www.sunriseyoga.in",
            "country": "IN",
            "added": "",
        },
    ],
    "rules": [
        "*: trim",
        "company: title",
        "contact: split-name",
        "phone: phone country=LB",
        "email: email",
        "website: domain into=domain",
        "website: url",
        "country: country",
        "added: date",
    ],
    "defaultCountry": "LB",
    "dedupeBy": [
        "phone",
        "email",
    ],
    "dedupeMatch": "any",
    "keep": "most-complete",
    "dropEmptyColumns": True,
    "renameFields": { "company": "businessName" },
    "exportCsv": True,
}

# Run the Actor and wait for it to finish
run = client.actor("opstoolkit/dataset-cleaner").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 '{
  "rows": [
    {
      "company": "Blue Door Bakery",
      "contact": "MARIA KHOURY",
      "phone": "03 123 456",
      "email": "Maria@BlueDoor.lb",
      "website": "www.bluedoor.lb/",
      "country": "lebanon",
      "added": "03/04/2024"
    },
    {
      "company": "Blue Door Bakery",
      "contact": "Khoury, Maria",
      "phone": "+961 3 123 456",
      "email": "maria@bluedoor.lb",
      "website": "https://bluedoor.lb",
      "country": "LB",
      "added": "2024-04-03"
    },
    {
      "company": "Cedar & Sons Ltd",
      "contact": "john smith jr",
      "phone": "+1 512 677 7667",
      "email": "orders@cedarsons.com",
      "website": "HTTP://CedarSons.com/?utm_source=newsletter",
      "country": "United States",
      "added": "March 5, 2024"
    },
    {
      "company": "CEDAR & SONS",
      "contact": "",
      "phone": "+1 (512) 677-7667",
      "email": "",
      "website": "cedarsons.com",
      "country": "USA",
      "added": ""
    },
    {
      "company": "Atlas Plumbing",
      "contact": "Dr. Rami Haddad",
      "phone": "71 555 888",
      "email": "",
      "website": "atlasplumbing.com.lb",
      "country": "Lebanon",
      "added": "12 Jan 2024"
    },
    {
      "company": "Atlas Plumbing SARL",
      "contact": "",
      "phone": "71555888",
      "email": "info@atlasplumbing.com.lb",
      "website": "",
      "country": "LB",
      "added": "N/A"
    },
    {
      "company": "Nile Dental Clinic",
      "contact": "Dr. Amira Hassan",
      "phone": "+20 100 123 4567",
      "email": "contact@niledental.eg",
      "website": "niledental.eg",
      "country": "Egypt",
      "added": "2024-01-12"
    },
    {
      "company": "Berlin Bike Shop GmbH",
      "contact": "Anna MÜLLER",
      "phone": "+49 30 901820",
      "email": "N/A",
      "website": "https://www.berlinbike.de/shop",
      "country": "Germany",
      "added": "2024-02-29"
    },
    {
      "company": "berlin bike shop",
      "contact": "",
      "phone": "+49 30 901820",
      "email": "info@berlinbike.de",
      "website": "berlinbike.de",
      "country": "DE",
      "added": ""
    },
    {
      "company": "Cafe Beirut",
      "contact": "",
      "phone": "not a number",
      "email": "hello@cafebeirut",
      "website": "cafebeirut.com",
      "country": "Lebanon",
      "added": "n/a"
    },
    {
      "company": "Sunrise Yoga",
      "contact": "Priya Patel",
      "phone": "+91 98765 43210",
      "email": "priya@sunriseyoga.in",
      "website": "sunriseyoga.in/",
      "country": "india",
      "added": "05/03/2024"
    },
    {
      "company": "",
      "contact": "",
      "phone": "",
      "email": "",
      "website": "",
      "country": "",
      "added": ""
    },
    {
      "company": "Sunrise Yoga Studio",
      "contact": "PRIYA PATEL",
      "phone": "",
      "email": "PRIYA@sunriseyoga.in",
      "website": "www.sunriseyoga.in",
      "country": "IN",
      "added": ""
    }
  ],
  "rules": [
    "*: trim",
    "company: title",
    "contact: split-name",
    "phone: phone country=LB",
    "email: email",
    "website: domain into=domain",
    "website: url",
    "country: country",
    "added: date"
  ],
  "defaultCountry": "LB",
  "dedupeBy": [
    "phone",
    "email"
  ],
  "dedupeMatch": "any",
  "keep": "most-complete",
  "dropEmptyColumns": true,
  "renameFields": {
    "company": "businessName"
  },
  "exportCsv": true
}' |
apify call opstoolkit/dataset-cleaner --silent --output-dataset

```

## MCP server setup

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

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/tTUsxUdHAgiEk61Nm/builds/gpqEExkZjLpCnEYZA/openapi.json
