Dataset Toolkit: Dedup, Merge, Diff, Flatten avatar

Dataset Toolkit: Dedup, Merge, Diff, Flatten

Pricing

from $0.02 / 1,000 row processeds

Go to Apify Store
Dataset Toolkit: Dedup, Merge, Diff, Flatten

Dataset Toolkit: Dedup, Merge, Diff, Flatten

Remove duplicates, merge datasets, get new, changed and removed rows since the last run, or flatten nested data for spreadsheets. Streams millions of rows in 1 GB, works with limited permissions, integrations and AI agents, and never fails a run over empty data.

Pricing

from $0.02 / 1,000 row processeds

Rating

0.0

(0)

Developer

Rivetfinch

Rivetfinch

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

20 hours ago

Last modified

Categories

Features

Limited permissions

Share

Clean up and compare Apify datasets without writing code. Pick one or more datasets, choose an operation, and get the result as a new dataset. It is built for scheduled pipelines and AI agents: it runs with limited permissions, reads millions of rows in the default 1 GB of memory, and never fails a run because a dataset is empty.

What you get

Diff tells you what changed since the last scrape. Every output row is your own row plus two columns:

[
{"url": "https://shop.example.com/p/1", "title": "Trail Running Shoe", "price": 89.0, "inStock": true,
"_change": "changed", "_changedFields": ["price"]},
{"url": "https://shop.example.com/p/3", "title": "Merino Base Layer", "price": 59.5, "inStock": false,
"_change": "new", "_changedFields": []},
{"url": "https://shop.example.com/p/9", "title": "Camping Mug", "price": 12.0, "inStock": true,
"_change": "removed", "_changedFields": []}
]
  • _change is new, changed or removed (and unchanged if you ask for those rows too).
  • _changedFields names the fields that differ, so ["price"] means only the price moved.
  • This example compares with a base dataset, so a removed row is the old row as it was there.
  • In the change feed (diff against the previous run) a removed row carries only its key fields, because only fingerprints are remembered:
{"url": "https://shop.example.com/p/9", "_change": "removed", "_changedFields": []}

Dedup keeps one row per key. With Key fields set to url and "Ignore extra spaces" on (the default), this input:

urltitleprice
https://shop.example.com/p/1Trail Running Shoe89
https://shop.example.com/p/2Rain Jacket129
https://shop.example.com/p/1Trail Running Shoe89
␣␣https://shop.example.com/p/2␣Rain Jacket129

becomes:

urltitleprice
https://shop.example.com/p/1Trail Running Shoe89
https://shop.example.com/p/2Rain Jacket129

The status message says what happened in one line. On the built-in sample (6 rows) it reads: Dedup: 4 rows from 6 items in 1 dataset; 2 duplicates removed. A SUMMARY record in the run's key-value store has the details per dataset.

Try it with an empty input first: the Actor then runs on a small built-in sample, free of charge, so you can see the output. Any other input that names no dataset gives 0 rows and says what is missing.

Operations

Choose one under Operation. Every operation reads the datasets in the order you list them, streams them page by page, and writes to this run's own dataset.

Dedup: remove duplicates

FieldWhat it does
DatasetsOne or more datasets. Duplicates are removed across all of them.
Key fieldsFields that make two rows the same record, such as url or email. Several fields are combined (sku + store). Dot paths reach nested fields (seller.id). Empty: rows must match in every field.
Ignore fieldsWith no key fields, leave these out of the comparison (for example scrapedAt).
Ignore upper and lower case in keysExample.com and example.com count as the same. Off by default.
Ignore extra spaces in keysTrims spaces at the ends and collapses runs of spaces. On by default.
Which duplicate to keepfirst (default) or last. Last reads the data twice.
Output duplicates onlyOutput the rows dedup would remove instead, to check what counts as a duplicate.

Rows that have none of the key fields are kept and counted in SUMMARY.itemsWithoutKey.

Merge: combine datasets

Joins the datasets into one, in order. Rows may have different columns. Set Key fields to also remove duplicates (same options as dedup). Turn on Add source dataset column to get _sourceDatasetId on every row (this works in every operation).

Diff: new, changed and removed rows

FieldWhat it does
DatasetsThe new version.
Base datasetThe old version. Leave empty to compare with the previous run instead (see below).
Key fieldsWhat identifies the same record in both versions, such as url or id. Without key fields, rows are matched by their whole content, so a changed row shows as one removed and one new row.
Compare fieldsOnly these fields count as a change, for example price and inStock. Empty compares every field.
Ignore fieldsFields that change on every scrape and should not count, such as scrapedAt. Dot paths work (meta.fetchedAt).
Include unchanged rowsAlso output unchanged rows, labelled unchanged.
Name the changed fieldsFill _changedFields (on by default).

Output order: new and changed rows in the order of the new data, then removed rows. A missing field and a field set to null count as the same. A change inside a nested object is named by its top-level field (brand), unless you list the nested path in Compare fields.

Diff against the previous run. Leave Base dataset empty and set a State name such as daily-products. Each run remembers a fingerprint of every row under that name, in a key-value store the Actor creates in your account (dataset-toolkit-state). The next run with the same state name outputs only what is new, changed or removed since then. Put it on a schedule after your scraper and you get a change feed.

  • A State name is required, unless the Actor runs from a saved task: then the task gets its own state (task-<task ID>).
  • The first run outputs every row as new.
  • Removed rows carry the key fields only (for example just the url), because the Actor stores fingerprints, not your data.
  • Broken scrapes don't wipe the state. If the input is empty, or more than half of the remembered rows are missing, nothing is reported as removed, the state is kept, and the run says so. Turn on Allow mass removal when the rows really are gone.
  • Rows skipped by Skip first rows are not remembered, so they come back next run.
  • If you change Key fields, Compare fields, Ignore fields or the case and space options, the saved state starts again and the run says so.
  • Rows the run could not deliver (it hit Max rows or your maximum cost) are not remembered, so they come back next run. Removed rows are only reported after a run that read every input to the end.

Flatten: nested data into plain columns

Turns {"brand": {"name": "Northpeak"}, "tags": ["running", "trail"]} into brand.name, tags.0, tags.1 columns for spreadsheets and CSV.

FieldWhat it does
Column separator. by default; _ gives brand_name.
Listsindex: one column per element. join: plain values in one cell (running, trail). json: the list as JSON text.
Join lists withThe text between joined values.
Max depthHow many levels to open; deeper objects stay as JSON text.
Keep only the first N list elementsSo 50 images don't become 50 columns.

Shape the output (every operation)

Applied to each output row in this order:

  1. Filter: Filter field plus Filter pattern (text or a regular expression, ignoring case), and Filter mode keep or drop. With no pattern, a row matches when the field has any value. In diff you can filter on _change, for example the pattern ^new$.
  2. Pick fields: only these columns, in this order. A dot path such as address.city becomes a column named address.city; a missing value comes out empty. _change, _changedFields and _sourceDatasetId are always kept.
  3. Omit fields: drop these columns (dot paths drop nested fields).
  4. Rename fields: an object of old name to new name, for example {"title": "name"}.
  5. Skip first rows and Max rows (offset and limit).

Pricing

$0.02 per 1,000 rows processed ($0.00002 per row).

  • What counts: each row read from your input datasets, including the base dataset in a diff. Each row counts once, even when an operation reads the data twice. You pay for the exact number of rows, with no rounding.
  • What you pay for is input, not output: a diff that finds only a handful of changes in a million rows costs the same as one that finds many.
  • Your maximum cost per run is respected. The run stops reading when it is reached and still delivers the rows it has finished. A diff run then remembers only the rows you received, so the rest come back next time.

Use it in a pipeline

After a scraper (integration). On your scraper, add an integration that runs this Actor when a run succeeds, and in its input put:

{
"operation": "dedup",
"datasetId": "{{resource.defaultDatasetId}}",
"keyFields": ["url"]
}

Dataset ID is the field made for this: it gives the run read access to the scraper's dataset. If the scraper's run had no results, this run succeeds with no rows instead of failing.

A daily change feed. Schedule a task with:

{
"operation": "diff",
"datasetId": "{{resource.defaultDatasetId}}",
"keyFields": ["url"],
"ignoreFields": ["scrapedAt"],
"stateName": "daily-products"
}

Each run outputs only new, changed and removed products. Chain another integration (email, Sheets, a webhook) on this Actor's dataset to get alerts.

Through the API. Pass dataset IDs in datasets (a named dataset as username~dataset-name):

{"operation": "merge", "datasets": ["aBcD1234eFgH5678i", "jKlM9012nOpQ3456r"], "keyFields": ["email"], "caseInsensitive": true}

Use it from an AI agent

The Actor runs with limited permissions, so agents using Apify's MCP server can call it. Tips for agents:

  • Put dataset IDs in datasets (an array of strings). That field grants read access; datasetIds does not (see Limits).
  • keyFields are the fields that identify a duplicate; pickFields are the columns to return. They are different settings.
  • Read the run's status message first: it says how many rows came out and names any dataset that could not be read, with the fix. Unknown input keys are listed there too, never silently ignored.
  • The SUMMARY record in the default key-value store has per-dataset counts.

Example request: "Remove duplicate leads by email from datasets A and B, ignoring case, and return only name, email and company":

{"operation": "dedup", "datasets": ["A", "B"], "keyFields": ["email"], "caseInsensitive": true, "pickFields": ["name", "email", "company"]}

Run summary

The SUMMARY record holds, per input dataset: the status (ok, empty, not_found, no_access, invalid or error), items read, whether it was read to the end, time taken, and a message with the fix when something went wrong. It also has rows out per change type, duplicates found and removed, rows filtered out, rows without a key, why the run stopped early (row limit or cost limit), unknown input keys, warnings, and the diff state's size.

Limits and good to know

  • Limited permissions (checked 2026-11-18 against Apify's documentation). The Actor can read your datasets only when they are named in a field that declares a dataset resource: Datasets, Base dataset and Dataset ID. Apify adds those to the run's access at start, whether you pick them or type an ID or name, including from the API, an agent or an integration template such as {{resource.defaultDatasetId}}. Anything else is outside that access:
    • Dataset or run IDs as text (datasetIds) take IDs, username~dataset-name or Apify links, not plain names. They are tried, and read only when Apify allows it, for example a dataset set to "Anyone with ID can read". Otherwise the run names each one and tells you to move it to Datasets.
    • The Actor never creates a dataset: a name Apify doesn't resolve is reported as not found.
    • Run IDs are looked up to find the run's dataset, which needs read access to that run. When Apify refuses, the run says so; use the run's dataset ID in Datasets instead.
    • The integration payload. When the Actor is started by an integration and no dataset is given anywhere else, it tries the triggering run's dataset from the payload. Apify's documentation does not say whether that read is allowed, so put {{resource.defaultDatasetId}} in Dataset ID as shown above; that always works.
  • Output always goes to this run's own dataset, which works under limited permissions. The diff state lives in a key-value store the Actor creates, named dataset-toolkit-state.
  • Memory. The Actor keeps a short fingerprint per row, never the rows. Tested on generated product data (about 450 bytes per row) with 1,000,000 rows: dedup used about 130 MB, dedup keeping the last duplicate about 170 MB, diff against a base dataset about 230 MB and diff against the previous run about 370 MB, all inside the default 1 GB. Diff against the previous run needs roughly 300 bytes per remembered row of 12 fields; each extra field adds 4 bytes while Name the changed fields is on.
  • Too big for the memory you picked? Before reading anything, the run estimates the memory it needs from the datasets' sizes. If that doesn't fit, it stops at once, charges nothing, and says which memory setting to rerun with.
  • Diff against a base dataset reads the base twice (once to remember it, once to output removed rows). The second read is skipped when nothing was removed.
  • Order. Rows come out in input order. With Which duplicate to keep set to last, the kept row appears where its last copy was.
  • Numbers. In diff, 1 and 1.0 count as the same value. As a key, "1" (text) and 1 count as the same, but in diff a switch from one to the other is a change.
  • Safe to restart. If Apify moves the run to another server or restarts it, the run continues where it stopped. Rows already delivered are not delivered or charged again, and the diff state is saved once. Progress is kept in the run's own key-value store under PROGRESS and removed when the run finishes.
  • Never fails over data. An empty dataset gives a successful run with 0 rows. A dataset that can't be read is named in the status message with the fix, and the other datasets are still processed. The run only fails when the input itself can't be used, such as an invalid regular expression, and the message says what to change.