Merge & Dedup Datasets: Remove Duplicates, Only New Items avatar

Merge & Dedup Datasets: Remove Duplicates, Only New Items

Pricing

from $1.90 / 1,000 batch of 1,000 output items

Go to Apify Store
Merge & Dedup Datasets: Remove Duplicates, Only New Items

Merge & Dedup Datasets: Remove Duplicates, Only New Items

Merge any number of Apify datasets and remove duplicates by the fields you choose (or the whole item). Keep the first or newest copy, or output only items not seen in earlier runs: ideal after a scheduled scraper. Streams millions of items. Duplicates are free; $0.0019 per 1,000 items output.

Pricing

from $1.90 / 1,000 batch of 1,000 output items

Rating

0.0

(0)

Developer

Charles Markette

Charles Markette

Maintained by Community

Actor stats

0

Bookmarked

5

Total users

4

Monthly active users

a day ago

Last modified

Categories

Share

Merge & Deduplicate Datasets (only new items, fast)

Combine any number of Apify datasets into one clean dataset:

  • Remove duplicates by the fields you choose (url, id, seller.id …), or by the whole item when you choose none.
  • Keep the first or the last copy. With "last", the newer dataset wins, which is handy when re-scraping.
  • Only new items: remember what earlier runs returned, and output just the new ones. This is the classic setup for a scheduled scraper that should only alert you about new listings, leads or prices.
  • Clean up: drop items missing required fields, keep only some fields, remove others, ignore letter case or extra spaces in keys, and tag each item with the dataset it came from.

With "keep first" it streams items and holds only an 8-byte fingerprint per unique key, so a run at the default 1 GB memory handles several million unique items. "Keep last" has to hold one copy of each unique item until the end, so give it more memory for big datasets. It runs with limited permissions: it can only read the datasets you select and write its own output and memory.

Typical setups

After a scraper (Integrations): in your scraper's task, go to Integrations → Connect Actor or task, pick this Actor, and use:

{
"datasetIds": ["{{resource.defaultDatasetId}}"],
"mode": "onlyNew",
"dedupFields": ["url"],
"stateName": "my-listing-monitor"
}

Each scheduled run then outputs only listings that weren't in any earlier run. The fixed stateName matters because every scraper run creates a new dataset. The memory is saved as the run goes (at least every 15 seconds, and right away when the cost limit is hit or the run is migrated or aborted), so after a timeout or crash the next run repeats at most the last few seconds of items.

Merge several runs: pick the datasets, set dedupFields to ["id"] and keep to last.

Input

FieldNotes
DatasetsOne or more datasets, processed in the order given.
ItemsA JSON array to deduplicate instead of datasets (used when no dataset is picked).
ModeRemove duplicates, only new since earlier runs, or just merge.
Deduplicate by fieldsDots for nested fields. Empty = compare whole items.
Which duplicate to keepFirst (streams) or last (keeps one buffered item per key).
Ignore letter case / extra spacesApplied to the key fields only.
Drop items missing these fieldsMissing, empty string, empty list or empty object all count as missing. Works in every mode.
Output only these fields / Remove these fieldsShape the output.
Add _sourceDatasetRecords where each item came from.
Max output itemsOptional cap.
Monitoring nameFor "only new": runs with the same name (and the same dedup settings) share one memory. Without a name, a saved task keeps its own memory; otherwise the memory belongs to that exact set of datasets.

Output

  • Dataset: the unique (or merged) items.
  • Key-value store OUTPUT: counts of items read, duplicates removed, items missing required fields, and items output.

Pricing

You pay per 1,000 items written, and each started block of 1,000 counts as one. Items that are read but removed as duplicates are free. If you set a maximum cost per run, the Actor stops cleanly at that limit, and in "only new" mode it remembers only the items it actually returned.

Notes

  • "Only new" remembers about 5 million keys per memory, then forgets the oldest (in blocks of 100,000).
  • Don't run two "only new" runs with the same memory at the same time; the one that finishes last wins.
  • Keys are compared by type: 1 and "1" are different keys. Changing the dedup fields or the case/space options starts a fresh memory.
  • Keys are compared as compact 64-bit fingerprints. Two different keys colliding is astronomically unlikely, but not impossible.