Merge & Dedup Datasets: CSV, Excel, JSON avatar

Merge & Dedup Datasets: CSV, Excel, JSON

Pricing

from $0.21 / 1,000 rows written

Go to Apify Store
Merge & Dedup Datasets: CSV, Excel, JSON

Merge & Dedup Datasets: CSV, Excel, JSON

Merge several Apify datasets into one and remove duplicate rows by the fields you choose. Streams the rows in pages; tested with 2 million unique keys in 512 MB. Export as JSON, CSV or Excel.

Pricing

from $0.21 / 1,000 rows written

Rating

0.0

(0)

Developer

Mr. Wolf

Mr. Wolf

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

5 hours ago

Last modified

Features

Limited permissions

Share

Merge several Apify datasets into one and remove duplicate rows by the fields you choose for $0.30 per 1,000 rows, then export JSON, CSV or Excel.

Merge several Apify datasets into one and remove duplicate rows by the fields you choose. Rows are streamed in pages; memory grows only with the number of distinct keys (tested with 2 million unique keys in 512 MB). Export the result as JSON, CSV or Excel.

How to use

  1. Pick the datasets. In Datasets to merge, choose one or more datasets. They are read in the order you list them; duplicate IDs are ignored.
  2. Write the key fields. In Fields to dedupe on, list the fields that identify a row (for example url). Rows with the same values in all of them are duplicates. Leave the list empty to compare the whole row.
  3. Run and export. The merged rows land in the run's default dataset. Open the Storage tab and export as JSON, CSV, Excel, XML or HTML.

Input

FieldTypeDescriptionDefault
datasetIdsarrayDatasets to merge (resource picker). At least one.required
dedupFieldsarray of stringsFields that identify a duplicate. Empty means the whole row.[]
keepfirst or lastWhich row to keep among duplicates.first
fieldsarray of stringsOutput only these fields. Cannot be combined with omitFields.all
omitFieldsarray of stringsRemove these fields from the output. Cannot be combined with fields.none

Example input:

{
"datasetIds": ["aBcDeFgHiJkLmNoPq", "rStUvWxYzAbCdEfGh"],
"dedupFields": ["url"],
"keep": "first",
"omitFields": ["scrapedAt"]
}

Output

Rows are written to the default dataset with the shape of the source rows. A summary is saved in the key-value store record OUTPUT:

{
"rowsRead": 12500,
"rowsWritten": 9800,
"duplicatesRemoved": 2700,
"rowsWithoutKey": 0,
"chargeLimitReached": false,
"perDataset": [
{ "datasetId": "aBcDeFgHiJkLmNoPq", "rowsRead": 7000 },
{ "datasetId": "rStUvWxYzAbCdEfGh", "rowsRead": 5500 }
]
}

chargeLimitReached is true when the run stopped because it reached the maximum charge you set for the run. The output is then incomplete: rowsWritten counts only the rows that were stored. Raise the maximum charge and run again to merge every row. The run still ends as succeeded, with a warning in the log.

Integrations

Sample Make and n8n flows are in docs/integrations/. They call run-sync-get-dataset-items, which waits at most 300 seconds: for large merges start the run with POST /v2/acts/mr.wolf~merge-dedup-datasets/runs and read the default dataset when the run has finished.

Pricing

Pay per event: $0.30 per 1,000 rows written to the dataset. No start fee. Duplicates that are removed are not charged. Failed runs are free: you pay only for rows actually delivered, so a run that fails before writing any row costs nothing.

Apify planPrice per row writtenPer 1,000 rows
Free$0.00030$0.30
Bronze$0.00027$0.27
Silver$0.00024$0.24
Gold, Platinum, Diamond$0.00021$0.21

Example: merging two datasets of 10,000 rows each with 4,000 duplicates writes 16,000 rows and costs $4.80 on the Free plan.

Limitations

  • Rows whose key fields are all missing, null or empty are kept and are not deduplicated. They are counted in rowsWithoutKey.
  • No conversion between numbers and strings: 1 and "1" are different keys.
  • keep: "last" reads the datasets twice, so it takes longer on large inputs.
  • If a field in dedupFields is not found on the first non-empty page of data, the run fails early and lists the fields that are available.
  • Use either fields or omitFields, not both.
  • fields and omitFields are applied after deduplication: duplicates are always detected on the full source row (or on dedupFields), never on the projected row.
  • Every dataset is checked before the first row is written. An unknown or inaccessible dataset ID fails the run with dataset not found or not accessible: <id> and nothing is charged.
  • With keep: "last", rows appended to a source dataset while the run is in progress are ignored (each dataset is read up to the row count found in the first pass).
  • Memory grows with the number of distinct keys, about 100-120 bytes each. Measured locally with Node.js limited to 512 MB of heap: 2 million unique keys used about 470 MB of process memory, 4 million about 670 MB, 5 million ran out of memory (same result for keep: "first" and keep: "last"). With 512 MB of run memory stay under 2 million distinct keys; for up to 4 million give the run 1 GB. Rows that are duplicates of a key already seen add no memory.

FAQ

Can I try it without my own data? Yes. Use the public sample dataset UTAnv4EVvzl4RfYff (5 rows, 2 duplicates by url) with dedupFields: ["url"]. The run writes 3 rows.

How do I find the ID of my dataset? Open the run of the scraper in Apify Console and go to Storage > Dataset, or pick the dataset directly in the Datasets to merge field.

Which copy of a duplicate is kept? With keep: "first" (default) the first row in input order is kept. With keep: "last" the last one is kept, at its original position.

Can I deduplicate on more than one field? Yes. List several fields in dedupFields (for example ["name", "city"]). Two rows are duplicates only when all the listed fields are equal.

Are text comparisons case-insensitive? No. Values are compared exactly as they are stored. "ACME" and "acme" are different keys.

How do I export to CSV or Excel? Open the default dataset of the run and use Export, or call the dataset items API with format=csv or format=xlsx.

Does it modify my source datasets? No. The Actor only reads them (limited permissions, read access to the datasets you select) and writes the result to its own dataset.