# Merge & Dedupe Datasets – Company & Lead Deduplication (`perceptr0n/merge-dedupe-datasets-company-leads`) Actor

Datasets, files or inline JSON in, one merged dataset without duplicates out – streaming, on small memory, with limited permissions. Company mode to deduplicate leads: lead lists in, one row per company out, matched by company name, website domain, email domain or phone, with the reason in each row.

- **URL**: https://apify.com/perceptr0n/merge-dedupe-datasets-company-leads.md
- **Developed by:** [Perceptron Data](https://apify.com/perceptr0n) (community)
- **Categories:** Developer tools, Lead generation, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Merge & Company Dedupe

Datasets, files or rows in, one merged dataset without duplicates out – and for lead lists one row per company, with the reason for every merge. Rows that share a website domain, an email domain, a phone number or the same company name without its legal form at the same place become one row; `matchedBy` says why.

<sub>Part of Perceptron Data · Tools</sub>

**Limits:** nothing is fetched from the web – a run reads the datasets, records and files you give it, nothing else. Companies are matched by fixed rules on what is in your rows: two differently abbreviated names are not guessed to be the same company, and two different websites stay two companies even when they share a phone number. Branches of one company become one row in company mode. A file may have up to 400 MB; a company list of several hundred thousand rows needs more memory, and the run says so before it starts instead of stopping halfway.

| Source | Company | Website | Phone | Place |
|---|---|---|---|---|
| map listing | Muster Autohaus GmbH & Co. KG – Filiale Nord | `https://www.example.com/kontakt?utm_source=maps` | 030 1234567 | 10115 Berlin |
| contact export | Muster Autohaus GmbH & Co. KG | `example.com` | +49 30 123 45 67 | 10115 Berlin |
| job board | MUSTER AUTOHAUS GmbH & Co. KG Niederlassung Berlin | – | – | 10117 Berlin |

→ one row with `mergedRows: 3` and `matchedBy: ["domain", "phone", "company_name_place"]`. *A made-up company in the shape of real rows.*

Three modes:

- **`dedupe`** (default) – remove rows that agree in the fields you name, or in every field. Case, blanks, `https://www.`, tracking parameters and the way a phone number is written do not make two rows different.
- **`merge`** – put several sources into one dataset, in the order you give them.
- **`companies`** – one row per company. Every merged row carries `mergedRows`, `matchedBy`, the shared values in `matchEvidence` and the `sources` it was made from; empty fields are filled from the other rows.

Runs with **limited permissions**: datasets and key-value stores are passed in fields that give the run read access to exactly these storages. No login, no API key, no proxy.

### How to use – step by step

1. Click **Try for free** on this page (a free Apify account is enough). The input form opens empty; a run without any input processes ten example rows so you can see the output.
2. Pick your datasets under **Datasets** – the order is their rank – or paste addresses of CSV, JSON or JSON Lines files under **File addresses**, or rows under **Rows in the input**.
3. Choose **What to do**: remove duplicates, merge only, or one row per company.
4. For duplicates, name the **fields that make two rows the same** (for example `url` or `email`); leave them empty to compare whole rows.
5. Click **Start**. The result is in the **Output** tab; the record `SUMMARY` in the key-value store says how many rows were read per source, written and found to be duplicates, and – in company mode – why rows were merged and which links were not drawn.
6. To check the decisions first, set **What to write** to `all`: every row comes back with its group number.

### Use cases

- **Lead lists from several sources** – map listings, a directory export, job ads and your CRM export describe the same companies in four spellings; get one row per company with the best-filled fields.
- **Before an outreach or enrichment run** – pay for every company once, not for every spelling of it.
- **Scheduled scrapes** – merge the datasets of several runs and keep each URL, product or job once.
- **Cleaning one dataset** – remove exact duplicates that differ in case, blanks or tracking parameters.
- **AI agents and workflows** – one tool call turns several result sets into one list; the status message and `SUMMARY` say exactly what happened.

### Input examples

Remove duplicates from two datasets by URL, keep the row from the top-ranked dataset:

```json
{ "datasets": ["aBcDeFgHiJkLmNoPq", "rStUvWxYz01234567"], "dedupeFields": ["url"] }
```

One row per company from a map scrape, a contact export and rows of your own:

```json
{
  "datasets": ["aBcDeFgHiJkLmNoPq"],
  "fileUrls": ["https://files.example.org/contacts.csv"],
  "items": [{ "company": "Muster Autohaus GmbH & Co. KG", "website": "example.com", "owner": "Anna" }],
  "mode": "companies",
  "defaultCountry": "DE"
}
```

Look at every decision before you rely on it:

```json
{ "datasets": ["aBcDeFgHiJkLmNoPq"], "mode": "companies", "output": "all", "maxRows": 2000 }
```

Keep only German rows with a website, write three columns, and also append the result to a dataset of yours:

```json
{
  "datasets": ["aBcDeFgHiJkLmNoPq"],
  "dedupeFields": ["website"],
  "filters": [{ "field": "countryCode", "op": "eq", "value": "DE" }, { "field": "website", "op": "exists" }],
  "keepFields": ["title", "website", "phone"],
  "renameFields": { "title": "companyName" },
  "outputDataset": "collected-leads"
}
```

#### Input fields

| Field | Meaning |
|---|---|
| `datasets` | Apify datasets (IDs), in rank order. The run gets read access to exactly these. `datasetIds` is read as the same field. |
| `fileUrls` | Public addresses of CSV (with header row), JSON (a list of objects) or JSON Lines files; `.gz` is unpacked. |
| `keyValueStore`, `recordKeys` | A key-value store and the keys of records that hold rows, e.g. the `OUTPUT` of another run. |
| `items` | Rows given directly as a JSON list. |
| `mode` | `dedupe` (default), `merge` or `companies`. |
| `dedupeFields` | Fields that make two rows the same; empty = the whole row. Nested fields as `address.city`. `fields` is read as the same field. |
| `normalize` | On by default: ignore case, runs of blanks, `https://www.`, a trailing slash, tracking parameters and the spelling of phone numbers. |
| `keep` | `first` (default in `dedupe`), `last`, `mostComplete`, or `merge` (default in `companies`): which row stays. |
| `output` | `unique` (default), `duplicates` (the removed rows) or `all` (every row with its `matchGroup`). |
| `matchOn` | Company mode: which marks may link rows – `domain`, `email_domain`, `phone`, `company_name`. Default: all. |
| `nameMatch` | `with_place` (default): the name counts together with the same postal code or town. `anywhere`: the name alone counts. |
| `companyNameField`, `websiteField`, `emailField`, `phoneField`, `cityField`, `postalCodeField` | Name a field to use it; empty = found by its usual names, in every source separately. |
| `defaultCountry` | Country of phone numbers written without a country code, when the row names none. |
| `keepFields`, `dropFields`, `renameFields` | Columns to keep, to drop, to rename – applied after duplicates are found. |
| `filters`, `filterMode` | Keep rows that match conditions (`eq`, `ne`, `contains`, `notContains`, `exists`, `missing`, `gt`, `gte`, `lt`, `lte`); `all` or `any`. |
| `addSourceField` | Add `sources` (source and row number) to every row. |
| `outputDataset` | A dataset of yours that also receives the rows; the run gets read and write access to exactly this one. `outputDatasetId` is read as the same field. |
| `maxRows` | Read at most this many rows over all sources – for a small trial. |

### Output example

A merged row in company mode (`keep: merge`): the row of the top-ranked source, its empty fields filled from the others, and four fields that explain the merge.

```json
{
  "title": "Muster Autohaus GmbH & Co. KG – Filiale Nord",
  "website": "https://www.example.com/kontakt?utm_source=maps",
  "phone": "030 1234567",
  "postalCode": "10115",
  "city": "Berlin",
  "countryCode": "DE",
  "companyName": "Muster Autohaus GmbH & Co. KG",
  "email": "info@example.com",
  "company": "MUSTER AUTOHAUS GmbH & Co. KG Niederlassung Berlin",
  "mergedRows": 3,
  "matchedBy": ["domain", "email_domain", "phone", "company_name_place"],
  "matchEvidence": {
    "domain": "example.com",
    "email_domain": "example.com",
    "phone": "+49301234567",
    "companyNameKey": "musterautohaus",
    "postalCode": "10115"
  },
  "sources": [
    { "source": "dataset:aBcDeFgHiJkLmNoPq", "row": 17 },
    { "source": "file:1:files.example.org/contacts.csv", "row": 3 },
    { "source": "items", "row": 1 }
  ]
}
```

Rows that were not merged come out as they went in. With `output: duplicates` or `all`, every row carries `matchGroup`; in company mode `all` also adds `companyNameKey`, the name as it was compared.

The **Output** tab shows the rows in three views: **Rows** with every field, **Lead columns** with `company`, `website`, `email`, `phone`, `postalCode` and `city` next to the fields that explain a merge (rows that name these fields differently show empty cells there), and **Merged companies** with the reasons only.

The record `SUMMARY` of a run holds: its `status` (`done`, or `rejected` with the reason in `error` – see "What does a run cost?"), rows read per source, rows written, rows charged, duplicates found, merged companies per reason, the fields used for name, website, email, phone and place, rows without any usable mark, and every link that was not drawn, with its reason and examples.

### When two rows are the same company

| `matchedBy` | Rule | Never linked when |
|---|---|---|
| `exact_key` | the fields in `dedupeFields` agree | – |
| `domain` | same registrable domain of the website (`shop.example.co.uk` = `example.co.uk`) | the address is shared by many companies: social profiles, map links, marketplaces, directories, link lists, short links |
| `email_domain` | same domain of the email address, or the email domain of one row is the website of another | the mailbox is a public provider (gmail.com, gmx.de, t-online.de …) |
| `phone` | same number after normalising, at least 7 digits | the country is unknown for a number without country code |
| `company_name_place` | same name without legal form, and the same postal code or town | the names carry different legal forms (`Müller GmbH`, `Müller AG`); a name without legal form has different postal codes in one town |
| `company_name` | same name without legal form – with `nameMatch: anywhere` | as above; the name is one everyday word (`Hotel`, `Consulting`) |

Locks that hold for every rule: two different websites are never put into one company; a domain, email domain or phone number that more than five differently named companies share (a switchboard, a portal) links nobody. Every link not drawn is counted in `SUMMARY`. Links carry over: A and B share a domain, B and C a phone number – one company.

The name without legal form: `FERCHAU GmbH Niederlassung Augsburg` and `Ferchau GmbH` are the same name; so are `Acme Inc.`, `ACME LLC` and `Acme S.r.l.`. The table of legal forms holds 63 forms in 102 spellings – from Germany, the rest of Europe, the US and Asia-Pacific. Short forms that are also words (`AS`, `AB`, `SA`, `Co`) count only at the end of a name, so `AS Roma` and `SAS Institute` keep their names.

### Limits – measured, not assumed

- **Checked by hand:** on a list of 1,095 real rows from three kinds of sources – 289 map listings, 150 rows with the legal notice data of their websites, 656 job ads – company mode formed 223 merged groups. All 223 were read one by one: 208 are the same company, 15 are two companies of one corporate group that share a website (for example a holding and its operating company), none put unrelated companies together (22 November 2026).
- **Missed on that list:** names that one source abbreviates (`Mgmt.` for `Management`, a leading abbreviation), and one operator with twelve listings under twelve different domains. Rather a duplicate missed than two companies merged.
- **One company per website:** a parent and its subsidiary with the same website become one row. Use `matchOn` without `domain` if you need them apart.
- **Job-board rows** carry the postal code of the workplace. A name with its legal form still counts as one company per town; a name without legal form does not.
- **Names in other scripts** (Cyrillic, Chinese, Japanese) are compared as written; their legal forms are not removed.
- **Two passes:** `companies`, and `dedupe` with `keep` other than `first`, read every source twice. A source that changes while the run reads it ends the run with a clear message.
- **Speed and memory:** Apify platform runs of 22 November 2026 with the default 512 MB and rows of about 1 kB – 15,000 rows deduplicated by two fields in 8 seconds (peak memory 112 MB), the same with `keep: merge` in 16 seconds, 4,500 rows in company mode in 7 seconds (88 MB). Larger inputs were measured outside the platform, on one computer under a 512 MB memory limit: one million rows in `dedupe` (peak 89 MB without Apify's own share), 100,000 rows in `companies` (180 MB). One million rows in company mode do not fit into 1 GB; the run then asks for more memory before it starts.

### Permissions and your data

The run reads the storages you pass in `datasets`, `keyValueStore` and `outputDataset` and the files behind `fileUrls` – nothing else in your account, and nothing on the web. An ID written anywhere else in the input is plain text and grants no access. File addresses must be public web addresses; addresses inside private networks are refused. Your rows are processed inside the run and written to the run's dataset; they are not sent anywhere else.

### What does a run cost?

$0.00005 per run start, then per input row processed – cheaper on bigger Apify plans:

| Your Apify plan | Per row in `merge` and `dedupe` (`row`) | Per row in `companies` (`company-row`) |
|---|---|---|
| Free | $0.0003 | $0.001 |
| Starter | $0.00027 | $0.0009 |
| Scale | $0.00024 | $0.0008 |
| Business & Enterprise | $0.0002 | $0.0007 |

| Example (Free plan, incl. $0.00005 run start) | Cost |
|---|---|
| 10,000 rows, duplicates removed | $3.00 |
| 10,000 rows, one row per company | $10.00 |
| The ten example rows of an empty input | $0.003 |

Prices are Apify free plan prices as of 22 November 2026. Counted is every input row the run processed, also rows the filters left out – reading them is the work. A run that cannot start its work is rejected: when a source cannot be read, when the input cannot be used, or when your maximum cost per run, the timeout or the memory would not be enough for the whole input. A rejected run reads, writes and charges no row – it costs the $0.00005 run start. It ends successfully with an empty dataset, its status message begins with `Rejected: No rows were processed —` and names what to change (the value that is needed, the source that cannot be read), and `SUMMARY` holds `"status": "rejected"` and the reason in `error`. So a schedule or an agent that reads only the run's status should also read `SUMMARY.status`. A run fails only when it stops after its work began; its message then says that the result is incomplete.

A maximum cost that misses the whole input by a few rows does not reject the run. A limit typed as rows × price is short of exactly one row, because the run start comes out of it first: up to one row, or 0.5% of the rows, the run does all its work, charges up to your limit and says how many rows it did without a charge (`rowsNotCharged` in `SUMMARY`). A run that Apify moves to another server, or that you resurrect, continues where it stopped: no row is written or charged twice.

### Coming from another merge tool?

Inputs written for other merge-and-dedup tools keep working where the meaning is the same: `datasetIds` → `datasets`, `fields` → `dedupeFields`, `output: unique-items` / `duplicate-items` → `unique` / `duplicates`, `mode: dedup-after-load` → `dedupe` (or `merge` when no fields are given), `outputDatasetId` → `outputDataset`, `fieldsToLoad` → `keepFields`, `limit` → `maxRows`, `appendDatasetIds` → `addSourceField`. The status message says what was read as what.

Rejected with a clear message, before any row is read: code in the input (`preDedupTransformFunction`, `postDedupTransformFunction` – use `filters`, `keepFields`, `dropFields`, `renameFields`), loading all runs of an Actor or task (`actorOrTaskId` – a run with limited permissions cannot list your runs; pass the dataset IDs), `datasetIdsOfFilterItems`, `offset`, `output: nothing`.

### Changelog

- **23 November 2026** – A run that cannot start its work is now rejected instead of failed: it ends successfully with no rows, the status message begins with `Rejected: No rows were processed —`, and `SUMMARY` holds `"status": "rejected"` and the reason in `error`. A maximum cost that misses the input by one row (the run start comes out of the limit first) or by up to 0.5% of the rows no longer rejects the run: it does all rows and charges up to the limit. `SUMMARY` of every run now has `status`.
- **22 November 2026** – Company names: `Stiftung` counts as part of the name. Two foundations whose names begin alike (`Evangelische Stiftung Nord`, `Evangelische Stiftung Süd`) stay two companies, and a foundation is no longer put together with a namesake that carries no legal form. A word such as `Region` or `Standort` stays when it is the first word of a name (`Region Hannover`).
- **22 November 2026** – New view **Lead columns** in the Output tab: the usual columns of a lead list next to the fields that explain a merge.
- **22 November 2026** – First version: merge datasets, records, files and rows; remove duplicates by fields or whole rows; company mode with reasons and shared values in every merged row; limited permissions; restart without double rows or double charges.

### Auf Deutsch: Datasets zusammenführen und Dubletten entfernen – eine Zeile je Firma

Datasets, Dateien oder Zeilen rein, ein zusammengeführtes Dataset ohne Dubletten raus – und bei Lead-Listen eine Zeile je Firma, mit dem Grund für jede Zusammenlegung. Zeilen mit derselben Website-Domain, derselben E-Mail-Domain, derselben Telefonnummer oder demselben Firmennamen ohne Rechtsform am selben Ort werden eine Zeile; `matchedBy` nennt den Grund. Es wird nichts aus dem Netz geholt: Der Lauf liest die Datasets, Records und Dateien, die Sie angeben.

- **`dedupe`** (Vorgabe): Zeilen entfernen, die in den genannten Feldern oder in allen Feldern übereinstimmen. Groß- und Kleinschreibung, Leerzeichen, `https://www.`, Tracking-Parameter und die Schreibweise von Telefonnummern machen keinen Unterschied.
- **`merge`**: mehrere Quellen in ein Dataset schreiben, in der angegebenen Reihenfolge.
- **`companies`**: eine Zeile je Firma. Jede zusammengelegte Zeile trägt `mergedRows`, `matchedBy`, die gemeinsamen Werte in `matchEvidence` und ihre `sources`; leere Felder werden aus den anderen Zeilen gefüllt.

Feste Regeln statt Vermutungen: Zwei verschiedene Websites werden nie zu einer Firma. Namen mit verschiedener Rechtsform (`Müller GmbH`, `Müller AG`) verknüpft der Name allein nie – teilen sie dieselbe Website, greift die Website-Regel. Öffentliche Postfächer (gmail.com, gmx.de, t-online.de), Profile in sozialen Netzen, Kartenlinks und Marktplätze verknüpfen niemanden. Jede nicht gezogene Verknüpfung steht mit Grund im Record `SUMMARY`.

Von Hand geprüft am 22. November 2026: In einer Liste aus 1.095 echten Zeilen (289 Karten-Einträge, 150 Zeilen mit Impressumsdaten, 656 Stellenanzeigen) entstanden 223 zusammengelegte Gruppen. 208 sind dieselbe Firma, 15 sind zwei Gesellschaften einer Unternehmensgruppe mit gemeinsamer Website, keine legt fremde Firmen zusammen.

Der Lauf arbeitet mit eingeschränkten Rechten (Limited Permissions): Er liest nur die Speicher, die in `datasets`, `keyValueStore` und `outputDataset` stehen. Kosten im Free-Tarif (Stand 22. November 2026): 0,0003 $ je verarbeiteter Zeile in `merge` und `dedupe`, 0,001 $ je Zeile in `companies`, dazu 0,00005 $ je Laufstart; in den Bezahltarifen weniger. Reicht das Kostenlimit, das Zeitlimit oder der Speicher nicht für die ganze Eingabe, ist eine Quelle nicht lesbar oder die Eingabe unbrauchbar, wird der Lauf vor der Arbeit abgelehnt: Er endet erfolgreich ohne Zeilen, berechnet keine Zeile, die Statusmeldung beginnt mit „Rejected: No rows were processed —“ und nennt den nötigen Wert, und `SUMMARY` trägt `"status": "rejected"`. Fehlen dem Kostenlimit nur eine Zeile oder bis zu 0,5 % der Zeilen, verarbeitet der Lauf trotzdem alles und berechnet bis ans Limit.

### FAQ

**Which fields does company mode use?**
The usual names are found by themselves, in every source separately: `companyName`, `company`, `organization`, `employer`, `title`, `name` for the name; `website`, `domain`, `homepage` for the website; `email`, `emails`; `phone`, `phones`, `telephone`; `city`, `postalCode`, `zip`, also inside `address`, `location` or `locations`. A field called `url` is not taken as the website, because it usually holds the address of the listing. Name a field in `companyNameField`, `websiteField` and the others to use it. `SUMMARY` lists the fields that were used.

**A row has a name but no company was matched – why?**
A name alone links nothing by default: `Elektro Müller` exists in many towns. The name counts together with the same postal code or town, or with `nameMatch: anywhere`. A row whose `name` sits next to `firstName` or `jobTitle` is a person, and its name is not taken as a company name.

**Which row stays when rows are merged?**
The row from the top-ranked source – the order of `datasets`, then `fileUrls`, then `recordKeys`, then `items`. With `keep: merge` its empty fields are filled from the other rows in the same order, and no filled value is overwritten. `keep: last` and `mostComplete` choose another row instead.

**Can I see what was removed?**
Yes. `output: duplicates` writes the removed rows with their group number, `output: all` writes every row. `unique` plus `duplicates` is always the whole input.

**How large can the input be?**
`dedupe` with `keep: first` and `merge` read the rows once and keep a few bytes per distinct row in memory – a million rows fit into the default 512 MB (measured, see Limits). `companies` reads twice and remembers the marks of every row; from about 300,000 rows on it needs 1 GB or more. The run checks this before it starts; when the memory is too small, it is rejected and names the memory to set. On the Apify Free plan your monthly credit is the limit: $5 covers about 16,000 rows in `dedupe` or 5,000 rows in `companies`.

**Does it work for people, products or URLs too?**
`dedupe` works for any rows: name the fields that identify one. Company mode is built for companies.

**Can an AI agent call it?**
Yes, through Apify's MCP server or the API. Every field has a default except the sources; the status message and `SUMMARY` say what was read, merged and left alone.

### More from Perceptron Data

| Actor | What it does |
|---|---|
| [Imprint & VAT Check](https://apify.com/perceptr0n/imprint-impressum-website-contact-scraper) | Domains in, company rows out: legal name, address, register number and EU VAT ID checked against VIES (Swiss UIDs excluded) |
| [Free Imprint & Contact Check](https://apify.com/perceptr0n/free-website-contact-imprint-scraper) | The same company row, free, for up to 10 websites per run |
| [Insolvency & Handelsregister Monitor](https://apify.com/perceptr0n/german-insolvency-handelsregister-monitor) | Companies in, one row per German company out: insolvency and register notices, EU VAT ID check, open positions |
| [Advertiser Check (Google & Bing)](https://apify.com/perceptr0n/google-ads-transparency-scraper) | Company list in, one row per company out: Google ads, Bing ads, ad counts, accounts |
| [Hiring Companies Germany](https://apify.com/perceptr0n/hiring-companies-germany) | Job and place in, one row per hiring company out: open positions, own website confirmed by its Impressum, contact data |
| [Arbeitsagentur Jobs](https://apify.com/perceptr0n/arbeitsagentur-jobs-scraper) | Keyword and place in, one row per job out: employer, salary range, home office, location |
| [XING Jobs](https://apify.com/perceptr0n/xing-jobs-scraper) | Keyword and place in, one row per XING job out: company, salary with its source, employment type, full text |
| [PDF to Markdown](https://apify.com/perceptr0n/pdf-to-markdown-converter) | Files in, clean Markdown out: real tables, OCR for scans, sections with page numbers |
| [Data Source Finder](https://apify.com/perceptr0n/dach-eu-data-source-finder) | A source in, the matching actor out – with fields, record count and run cost. Free |

### Support

Bug reports are welcome in the **Issues** tab.

So are feedback, ideas and suggestions for improvement – at any time, in the **Issues** tab or by e-mail to thom.ehr@gmail.com. Every message is read, and looked into and handled promptly.

**Custom Actors:** need another source, extra fields or a different delivery? Write to thom.ehr@gmail.com with the source and the data you need, or open an issue on this page. Prices are quoted per project.

# Changelog

This Actor's version history is a separate document: https://apify.com/perceptr0n/merge-dedupe-datasets-company-leads/changelog.md

# Actor input Schema

## `datasets` (type: `array`):

Apify datasets to merge, as dataset IDs — pick them here or pass `["id1", "id2"]` over the API. Their order is their rank: when rows are merged, the row from the top dataset is the base. Read access to exactly these datasets is all the run gets (limited permissions). `datasetIds` is read as the same field.

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

Public addresses of files with rows: a JSON list of objects, JSON Lines, or CSV with a header row (comma, semicolon or tab; .gz is unpacked). Up to 400 MB per file. Files come after the datasets in rank.

## `items` (type: `array`):

Rows given directly, as a JSON list of objects, e.g. `[{"company": "Acme GmbH", "website": "acme.example"}]`. They come last in rank. An ID written here is plain text: a dataset must be given in `datasets` to be read.

## `keyValueStore` (type: `string`):

A key-value store that holds records with rows (JSON list, JSON Lines or CSV). Name the records in `recordKeys`.

## `recordKeys` (type: `array`):

Keys of the records to read from `keyValueStore`, e.g. `OUTPUT` or `leads.csv`.

## `mode` (type: `string`):

`dedupe` (default) = remove duplicates: rows that agree in `dedupeFields` (or in every field) count once. `merge` = only put the sources together, remove nothing. `companies` = one row per company: rows that share a website domain, an email domain, a phone number, or the same company name without its legal form at the same place become one row, with the reason in `matchedBy`. `companies` is charged at the higher `company-row` price.

## `dedupeFields` (type: `array`):

Mode `dedupe`: two rows are duplicates when they agree in all of these fields, e.g. `["url"]` or `["email", "lastName"]`; nested fields as `address.city`. Empty = the whole row must agree. A row with no value in any of these fields is always kept. In mode `companies` the fields are an additional exact link (`exact_key`). `fields` is read as the same field.

## `normalize` (type: `boolean`):

On (default): `ACME` = `acme`, `https://www.example.com/?utm_source=x` = `example.com`, `+49 30 123 45 67` = `+49301234567`, runs of blanks count once. Off: values must be equal as stored. A missing field, null and an empty text are always the same.

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

`first` (default in `dedupe`) = the first row in the order of the sources. `last` = the last. `mostComplete` = the row with the most filled fields. `merge` (default in `companies`) = the first row, with its empty fields filled from the others in order; a filled value is never overwritten. `first` needs one pass over the rows, the others two.

## `output` (type: `string`):

`unique` (default) = the cleaned rows. `duplicates` = only the rows that were removed, each with its `matchGroup`. `all` = every row with its `matchGroup` (and `companyNameKey` in mode `companies`), to check every decision. No row disappears silently: `unique` plus `duplicates` is the input.

## `matchOn` (type: `array`):

Mode `companies`. `domain` = same registrable domain of the website (`shop.example.com` = `example.com`; social profiles, map links, marketplaces and link lists do not count). `email_domain` = same domain of the email address (public mailbox providers do not count). `phone` = same number after normalisation, at least 7 digits. `company_name` = same name without legal form, see `nameMatch`. Default: all four.

## `nameMatch` (type: `string`):

`with_place` (default) = the same name without legal form links two rows only when the postal code or the town is the same too (`Elektro Müller` in two towns stays two companies). `anywhere` = the name alone is enough — for lists of large companies with branches. One-word everyday names such as `Hotel` never link on the name alone.

## `companyNameField` (type: `string`):

Leave empty to have it found: `companyName`, `company`, `organization`, `employer`, `title`, `name` and similar, in every source separately. Name a field (e.g. `employer.name`) to use it first. The fields actually used are listed in the record `SUMMARY`.

## `websiteField` (type: `string`):

Leave empty to have it found (`website`, `domain`, `homepage`, `companyWebsite` …). A field `url` is not used unless you name it here, because it usually holds the address of the listing, not of the company.

## `emailField` (type: `string`):

Leave empty to have it found (`email`, `emails`, `contactEmail` …). Lists of addresses are read entry by entry.

## `phoneField` (type: `string`):

Leave empty to have it found (`phone`, `phones`, `telephone`, `phoneUnformatted` …).

## `cityField` (type: `string`):

Leave empty to have it found (`city`, `town`, `address.city` …). Without a town or postal code field, both are read from a one-line `address`.

## `postalCodeField` (type: `string`):

Leave empty to have it found (`postalCode`, `zip`, `plz`, `address.postalCode` …).

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

`030 1234567` and `+49 30 1234567` are the same number only when the country is known. It is taken from the row (`countryCode`, `country`) when there is one; otherwise from here. Without a country, numbers match only when they are written with the same digits.

## `keepFields` (type: `array`):

Only these fields are written, in this order (nested fields as `address.city`). Empty = all. Applied after duplicates are found, so a field can be compared and still left out. `fieldsToLoad` is read as the same field.

## `dropFields` (type: `array`):

Fields that are not written.

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

Old name → new name, e.g. `{"title": "companyName", "phoneUnformatted": "phone"}`. Applied to the rows written, after duplicates are found.

## `filters` (type: `array`):

A list of conditions, e.g. `[{"field": "countryCode", "op": "eq", "value": "DE"}, {"field": "website", "op": "exists"}]`. Comparisons: `eq`, `ne`, `contains`, `notContains`, `exists`, `missing`, `gt`, `gte`, `lt`, `lte`. Rows that do not match are read and charged, but not written.

## `filterMode` (type: `string`):

`all` (default) = every condition; `any` = at least one.

## `addSourceField` (type: `boolean`):

Adds the field `sources` to every row: the source and the row number in it. Merged rows always carry it.

## `outputDataset` (type: `string`):

Optional: an existing dataset of yours that also receives the rows written, for example a named dataset that collects the results of every run. The run gets read and write access to exactly this dataset. `outputDatasetId` is read as the same field.

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

Stops reading after this many input rows, counted over all sources in order — for a small trial on a large dataset. Empty = all rows. `limit` and `maxItems` are read as the same field.

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

The same as `datasets`, under the name other merge tools use. Hidden in the form; over the API both fields are read and get the same read access.

## `outputDatasetId` (type: `string`):

The same as `outputDataset`, under the name other merge tools use. Hidden in the form.

## Actor input object example

```json
{
  "mode": "dedupe",
  "normalize": true,
  "output": "unique",
  "matchOn": [
    "domain",
    "email_domain",
    "phone",
    "company_name"
  ],
  "nameMatch": "with_place",
  "filterMode": "all",
  "addSourceField": false
}
```

# Actor output Schema

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

The rows written: unique rows, removed rows or all rows with their group number, depending on `output`. Merged rows carry `mergedRows`, `matchedBy`, `matchEvidence` and `sources`.

## `resultsCsv` (type: `string`):

The same rows as CSV, for spreadsheets.

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

Not charged. Rows read per source, rows written, duplicates found, merged groups per reason, the fields used for name, website, email and phone, and every link that was not drawn, with its reason.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("perceptr0n/merge-dedupe-datasets-company-leads").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("perceptr0n/merge-dedupe-datasets-company-leads").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 '{}' |
apify call perceptr0n/merge-dedupe-datasets-company-leads --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,perceptr0n/merge-dedupe-datasets-company-leads"
        }
    }
}
```

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/fd86Ij4LcheWPoBvG/builds/BfUgPROFLZZom8o6Y/openapi.json
