Merge, Dedupe & Transform Datasets to CSV & JSON
Pricing
from $0.03 / 1,000 rows written
Merge, Dedupe & Transform Datasets to CSV & JSON
Merge Apify datasets and CSV, JSON or Excel files, remove duplicates, filter rows, rename and select columns, flatten nested JSON and export clean CSV, JSONL or XLSX. No code, limited permissions, built for scraping pipelines, n8n and AI agents. Pay per row.
Pricing
from $0.03 / 1,000 rows written
Rating
0.0
(0)
Developer
mcpkit
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
18 hours ago
Last modified
Categories
Features
Share
What is Merge, Dedupe & Transform Datasets
Merge, Dedupe & Transform Datasets merges Apify datasets and CSV, JSON, JSONL or Excel files into one clean table, removes duplicates, filters rows and reshapes columns in a single run, without writing code. Typical job: you scraped Google Maps five times, and you want one list without duplicate places, only places with a phone number, six columns, as a CSV.
- Merge any number of Apify datasets and file URLs (CSV, TSV, JSON, JSONL, XLSX) into one result.
- Remove duplicates by one or more fields (
placeId,url,email) or by the whole row. Keep the first or the last copy, optionally ignoring case and spaces. - Filter rows with simple conditions: equals, contains, greater than, regex, empty, in a list and more.
- Flatten nested JSON into flat columns (
address.city), ready for spreadsheets. - Select, rename and remove columns, sort and limit the result.
- Export to the dataset (download as CSV, JSON, Excel and more), to one CSV, JSONL or XLSX file with a direct link, or both. File-only mode is the fastest way to export large results.
It runs with limited permissions: it can read only the datasets you pass to it, so it is safe to give to AI agents and automation tools. It streams data page by page, so a million rows do not need a big machine. You pay per row written to the result; filtered-out rows and removed duplicates are free.
What you can use it for
- Scraping pipelines: merge the results of many runs of the same scraper (Google Maps, Instagram, Amazon, websites) and remove the duplicates.
- Lead lists: combine several lead files, keep only rows with an email or phone, and export a clean CSV for your CRM.
- Incremental updates: keep the newest version of each record with
keepLastwhen you merge old and new datasets. - AI agents and n8n: let an agent or workflow clean up scraped data before it reads it.
How to use
Apify Console
- Open the Actor. In Datasets, pick one or more datasets from your account. To add files, paste their URLs into File URLs.
- In Dedup fields, enter the field that identifies a duplicate, for example
placeId. Leave it empty to compare whole rows. - Optionally add Filters, Fields to keep, Rename fields, Sort by field and choose Also save as file.
- Click Start. The result is in the Output tab: the dataset rows and the
OUTPUTreport with the file link.
API
curl -X POST "https://api.apify.com/v2/acts/mcpkit~merge-dedup-datasets/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \-H "Content-Type: application/json" \-d '{"datasets": ["<DATASET_ID_1>", "<DATASET_ID_2>"],"dedupFields": ["placeId"],"filters": [{"field": "phone", "op": "not_empty"}],"fields": ["title", "phone", "website", "address", "totalScore"],"outputFile": "csv"}'
Dataset IDs passed through the API work the same way as datasets picked in the Console.
Apify MCP for Claude and Cursor
{"mcpServers": {"apify": {"url": "https://mcp.apify.com/?tools=mcpkit/merge-dedup-datasets","headers": { "Authorization": "Bearer <APIFY_TOKEN>" }}}}
Then ask: "Merge datasets A and B, remove duplicates by url and keep only rows where price is below 50." The agent calls the tool with the dataset IDs, dedupFields and filters, then reads the dataset.
Chain it after another Actor
In your scraper, open Integrations → Run Actor after, choose this Actor and set the input to {"datasets": ["{{resource.defaultDatasetId}}"], "dedupFields": ["url"]}. Every finished scraper run is cleaned automatically.
n8n and Make
- n8n HTTP Request node: method
POST, URLhttps://api.apify.com/v2/acts/mcpkit~merge-dedup-datasets/run-sync-get-dataset-items, query parametertoken= your Apify API token. - JSON body with dataset IDs from previous nodes:
{ "datasets": {{ JSON.stringify($json.datasetIds) }}, "dedupFields": ["placeId"], "outputFile": "csv" }
Input
| Field | Type | Description |
|---|---|---|
datasets | array | Apify dataset IDs or names (username~name works too). Required unless fileUrls is set. |
fileUrls | array | Public URLs of CSV, TSV, JSON, JSONL or XLSX files, up to 100 MB each. Apify dataset export links work too. |
addSource | boolean | Add _source (dataset ID or file URL) to each row. Default false. |
flatten | boolean | Flatten nested objects into a.b.c columns. Default false. |
flattenArrays | json / index | Arrays as a JSON string in one column, or one column per item (tags.0, tags.1). Default json. |
filters | array | Conditions {field, op, value, ignoreCase}. See the operators below. |
filterLogic | all / any | Every condition must match (AND) or at least one (OR). Default all. |
dedup | boolean | Remove duplicates. Default true. |
dedupFields | array | Fields that identify a duplicate. Empty = compare whole rows. |
dedupMode | keepFirst / keepLast | Which copy to keep. Default keepFirst. |
dedupNormalize | boolean | Ignore case and leading/trailing spaces when comparing. Default false. |
fields | array | Keep only these fields, in this order. Missing fields become null. |
renameFields | object | {"old name": "new name"}. |
omitFields | array | Remove these fields. |
sortBy | string | Sort by this field. Numbers sort as numbers, empty values go last. |
sortOrder | asc / desc | Default asc. |
limit | integer | Write at most this many rows. |
outputFile | none / csv / jsonl / xlsx | Save the result as one file. Default none. Required when outputTo is file or both. |
outputTo | dataset / file / both | Where rows go. file writes rows only to the file, with one summary row in the dataset. Default dataset. |
Field names can be dot paths into nested objects: address.city, reviews.0.text.
Processing order
The steps always run in this order: 1. Merge (datasets first, then files, in the order given) → 2. Flatten → 3. Filter → 4. Remove duplicates → 5. Select, remove and rename fields → 6. Sort and limit. So filters and dedupFields use the original field names, and sortBy can use the new name or the original one.
Filter operators
op | Keeps rows where the field... | Example |
|---|---|---|
eq / ne | equals / does not equal the value (numbers are compared as numbers, so "4.5" equals 4.5) | {"field": "city", "op": "eq", "value": "Paris"} |
gt, gte, lt, lte | is greater / less than the value (numbers, or text such as ISO dates) | {"field": "rating", "op": "gte", "value": 4} |
contains / not_contains | contains the text; for arrays, any item contains it | {"field": "categories", "op": "contains", "value": "Cafe"} |
regex | matches a regular expression | {"field": "email", "op": "regex", "value": "@gmail\\.com$"} |
in | equals one of the values | {"field": "country", "op": "in", "value": ["US", "CA"]} |
exists / not_exists | is present (even if null) / is missing | {"field": "website", "op": "exists"} |
empty / not_empty | is missing, null, "", [] or {} / has a value | {"field": "phone", "op": "not_empty"} |
Add "ignoreCase": true to any text condition to ignore letter case.
Input example
{"datasets": ["aBcD1234efGH5678i", "jKlM9012nOpQ3456r"],"fileUrls": ["https://example.com/old-leads.csv"],"dedupFields": ["placeId"],"dedupMode": "keepLast","filters": [{"field": "phone", "op": "not_empty"},{"field": "totalScore", "op": "gte", "value": 4}],"flatten": true,"fields": ["title", "phone", "website", "address.city", "totalScore"],"renameFields": {"address.city": "city", "totalScore": "rating"},"sortBy": "rating","sortOrder": "desc","outputFile": "xlsx"}
Output
Dataset
One dataset item per result row. The fields are your own fields after the steps above, for example:
[{"title": "Cafe One", "phone": "+33 1 23 45 67 89", "website": "https://cafe-one.fr", "city": "Paris", "rating": 4.8},{"title": "Shop Three", "phone": "+33 4 11 22 33 44", "website": null, "city": "Lyon", "rating": 4.5}]
Download it from the Output or Storage tab, or through the API, as CSV, JSON, JSONL, Excel, XML or HTML.
File-only output (outputTo: "file")
The rows are written only to the file. The dataset gets one summary row, so API, MCP and n8n callers that read the dataset get the link right away:
{"resultFileUrl": "https://api.apify.com/v2/key-value-stores/.../records/result.csv?signature=...", "resultFileFormat": "csv", "resultFileTruncated": false, "rowsWritten": 18250, "rowsRead": 25000, "rowsFilteredOut": 3100, "duplicatesRemoved": 3650, "chargeLimitReached": false, "failedSources": 0}
OUTPUT report and file
The OUTPUT record in the key-value store shows what happened to your rows and links to the file:
{"rowsWritten": 18250,"rowsRead": 25000,"rowsFilteredOut": 3100,"duplicatesRemoved": 3650,"chargeLimitReached": false,"sources": [{"source": "aBcD1234efGH5678i", "type": "dataset", "format": "dataset", "rowsRead": 20000, "invalidLines": 0, "error": null},{"source": "https://example.com/old-leads.csv", "type": "file", "format": "csv", "rowsRead": 5000, "invalidLines": 0, "error": null}],"outputFile": {"format": "xlsx", "key": "result.xlsx", "url": "https://api.apify.com/v2/key-value-stores/.../records/result.xlsx", "rows": 18250, "truncated": false},"datasetId": "xYz...","durationSec": 14.2}
- A source that cannot be read (wrong ID, broken file) is listed with an
error, and the run continues with the other sources. The run fails only if no source can be read. - JSONL lines that are not valid JSON are skipped and counted in
invalidLines. - CSV values stay as text, exactly as in the file. XLSX dates become ISO strings.
How much does it cost to merge and deduplicate datasets?
You pay per row written to the result. Rows removed by filters or as duplicates are free.
| Event | Price (Free plan) | Bronze | Silver | Gold |
|---|---|---|---|---|
| Actor start | $0.00005 | $0.00005 | $0.00005 | $0.00005 |
| Row written | $0.00005 | $0.000045 | $0.00004 | $0.000035 |
A row is charged once, whether it goes to the dataset, the file or both. The summary row in file-only mode is free. Examples:
| Rows in the result | Free plan | Gold plan |
|---|---|---|
| 1,000 (for example 3 datasets with 2,000 rows, half removed as duplicates) | $0.05 | $0.035 |
| 10,000 | $0.50 | $0.35 |
| 100,000 | $5.00 | $3.50 |
Set a maximum cost per run in the run options: the Actor stops when it reaches it, keeps the rows it already wrote (in the dataset and the file) and reports "chargeLimitReached": true.
FAQ
Why do I need to select datasets in the input?
The Actor runs with limited permissions: it can only read the datasets you pass in the datasets field, and nothing else in your account. This is safer for you and is why AI agents can use it. Pick the datasets in the Console or pass their IDs through the API. If a dataset is not found, check the ID; for a name, username~dataset-name always works.
How do I export large results?
Set outputTo to file and outputFile to csv, jsonl or xlsx. The rows are written straight to one file instead of the dataset, which is much faster for hundreds of thousands of rows and has no dataset write limits. Download the file from the link in the summary row or in OUTPUT. CSV and JSONL are the fastest; XLSX is limited by Excel to 1,048,575 rows. Use both if you also need the rows in the dataset, for example to read them with get-dataset-items in Apify MCP.
How many rows can it handle?
Without sorting, rows are processed as a stream: only a 64-bit fingerprint of each unique key is kept in memory for dedup, so the default 512 MB handles about 5 million unique rows (1 million rows take about 120 MB). For more, give the run more memory. Sorting and keepLast keep a small index per row, so they support up to 1,000,000 rows after filtering. Files can be up to 100 MB each. Excel files are limited by Excel itself to 1,048,575 rows; use CSV or JSONL for more.
Can I run custom JavaScript or Python?
No. All steps are declarative options, on purpose: no code means no security risk when an AI agent or a shared workflow builds the input, and no code to debug. If you need a step that is missing, open an issue.
How are duplicates detected?
With dedupFields, two rows are duplicates when all those fields are equal. Rows where all of these fields are empty are never treated as duplicates. Without dedupFields, whole rows are compared, ignoring the order of keys and the _source field. dedupNormalize ignores letter case and spaces around values, and treats 1 and "1" as equal.
Does it change my source datasets?
No. It only reads them. The result goes to the run's own dataset and key-value store.
How do I chain it after another Actor?
Use Integrations → Run Actor after on your scraper or task, as shown in How to use. In n8n or Make, call it with the dataset ID from the previous run.
How is it different from other dedup Actors?
It also merges files, filters, flattens, reshapes and sorts in the same run, runs with limited permissions so AI agents can call it, writes large results straight to a file, and costs $0.50 per 10,000 result rows on the Free plan.
Other tools from mcpkit
- PDF to Markdown & Text Extractor for LLM & RAG: PDF, Word, Excel, PowerPoint and scans (OCR) to Markdown, JSON tables and RAG chunks.
- Website Tech Stack Detector & Technology Lookup: CMS, frameworks, analytics, hosting, email provider and SaaS tools of any website.