# Dataset Dedupe, Merge and Filter - Any Actor, $0.25/1K (`dariandanciu/dataset-dedupe-merge-filter`) Actor

Merge any number of Apify datasets, remove duplicates on the fields you choose, filter rows and keep only the columns you need. Runs with limited permissions and chains after any Actor. $0.25 per 1,000 rows kept; removed rows are free.

- **URL**: https://apify.com/dariandanciu/dataset-dedupe-merge-filter.md
- **Developed by:** [Darian Danciu](https://apify.com/dariandanciu) (community)
- **Categories:** Developer tools, Automation, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.18 / 1,000 row kepts

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 Dedupe, Merge and Filter

**Merge Apify datasets, remove duplicates, filter rows and keep the columns you need.** It runs after any scraper, so the output of two or twenty runs becomes one clean dataset.

### Why use it

- **$0.25 per 1,000 rows kept.** Duplicates and filtered rows are free.
- **Runs with limited permissions.** It reads only the datasets you give it.
- **Dedupe your way.** Match on any fields, ignore case and spaces, and keep the first, the last or the most complete row.
- **Filter without code.** Twelve rule types, including number comparisons and regular expressions.
- **Handles big data.** With "first seen", rows stream through and only a small hash of each stays in memory.

### Input

| Field | Example |
|---|---|
| Datasets | One or more dataset IDs |
| Dedupe on these fields | `url`, or `company` and `title` together |
| Which duplicate to keep | First seen, Last seen, Most filled-in fields |
| Filters | `[{ "field": "price", "op": "lt", "value": 50 }]` |
| Keep only these fields | `title`, `price.amount` |

Leave the dedupe fields empty to compare whole rows.

### Filter rules

`eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `contains`, `notContains`, `in`, `exists`, `missing` and `matches` (a regular expression). Numbers written as text compare as numbers. Every rule must pass for a row to stay.

### Chain it after another Actor

Add this Actor as an integration on your scraper or task, and pass the finished run's dataset:

```json
{ "datasetIds": ["{{resource.defaultDatasetId}}"], "dedupeFields": ["url"] }
```

### Output

The kept rows, unchanged apart from any field selection. `RUN_SUMMARY` shows rows read, duplicates, filtered rows and rows written, for each dataset.

### Good to know

- Datasets are read in the order you list them, so with "first seen" the earlier dataset wins.
- "Last seen" and "most complete" hold rows in memory, up to 2 million unique rows. Give the run more memory for large datasets.
- A dataset that can't be read is reported in `RUN_SUMMARY`, and the others still run.

### Related Actors

More developer utilities by the same developer, with the same pay-per-result pricing:

| Actor | What it gets |
|---|---|
| [Bulk LLM Runner](https://apify.com/dariandanciu/bulk-llm-runner) | Run a prompt over every row with your own API key |
| [Bulk HTTP Requests](https://apify.com/dariandanciu/bulk-http-requests) | Any method, JSON parsed, at $0.50 per 1,000 |
| [Bulk File Downloader](https://apify.com/dariandanciu/bulk-file-downloader) | Save file links to storage, with hashes |
| [Video Frame Extractor](https://apify.com/dariandanciu/video-frame-grabber) | Frames from direct video links at $1 per 1,000 |
| [Audio & Video Transcriber](https://apify.com/dariandanciu/audio-video-transcriber) | Files and podcast feeds to text, with subtitles |
| [Bulk OCR](https://apify.com/dariandanciu/bulk-ocr-text-extractor) | Images and scanned PDFs to text, one row per page |
| [PDF Text Extractor](https://apify.com/dariandanciu/pdf-text-extractor-bulk) | PDF links to clean text for RAG and AI agents |
| [Bulk SEO Audit](https://apify.com/dariandanciu/bulk-seo-audit) | A score and ranked issue list for every page |
| [Article Extractor](https://apify.com/dariandanciu/article-extractor-markdown) | Clean text and Markdown from any article URL |

# Actor input Schema

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

One or more datasets to merge, in order. When chaining after another Actor, use its default dataset ID.

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

Rows given directly, read after the datasets.

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

Rows that match on all of these are duplicates. Leave empty to compare whole rows.

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

First keeps streaming order and uses little memory. Last and most complete hold rows in memory, up to 2 million.

## `ignoreCase` (type: `boolean`):

Treat "Ada" and " ada " as the same value when comparing.

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

Keep only rows that pass every rule. Each rule is {"field", "op", "value"}, where op is one of eq, ne, gt, gte, lt, lte, contains, notContains, in, exists, missing, matches.

## `includeFields` (type: `array`):

Leave empty to keep all fields. Dots reach nested values, like price.amount.

## `excludeFields` (type: `array`):

Fields to drop from every row.

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

Stop after writing this many rows.

## Actor input object example

```json
{
  "rows": [
    {
      "name": "Ada",
      "city": "London"
    },
    {
      "name": "ada ",
      "city": "Paris"
    },
    {
      "name": "Grace",
      "city": "New York"
    }
  ],
  "dedupeFields": [
    "name"
  ],
  "keep": "first",
  "ignoreCase": true,
  "filters": [],
  "maxRows": 1000000
}
```

# Actor output Schema

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

The output rows.

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

Counts, and anything that failed.

# 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": [
        {
            "name": "Ada",
            "city": "London"
        },
        {
            "name": "ada ",
            "city": "Paris"
        },
        {
            "name": "Grace",
            "city": "New York"
        }
    ],
    "dedupeFields": [
        "name"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dariandanciu/dataset-dedupe-merge-filter").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": [
        {
            "name": "Ada",
            "city": "London",
        },
        {
            "name": "ada ",
            "city": "Paris",
        },
        {
            "name": "Grace",
            "city": "New York",
        },
    ],
    "dedupeFields": ["name"],
}

# Run the Actor and wait for it to finish
run = client.actor("dariandanciu/dataset-dedupe-merge-filter").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": [
    {
      "name": "Ada",
      "city": "London"
    },
    {
      "name": "ada ",
      "city": "Paris"
    },
    {
      "name": "Grace",
      "city": "New York"
    }
  ],
  "dedupeFields": [
    "name"
  ]
}' |
apify call dariandanciu/dataset-dedupe-merge-filter --silent --output-dataset

```

## MCP server setup

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

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/5XcyjsaiArvDcYZ1q/builds/xT2t2CTuTUzXRJr6h/openapi.json
