# Dataset Transform Pro: Merge, Filter, Dedupe, Only New Rows (`ucchiii/dataset-transform-pro`) Actor

All-in-one data cleanup for Apify datasets and CSV, JSON, Excel or Google Sheets files: merge, filter, flatten and rename, exact or fuzzy dedupe, explode arrays, keep only rows new since the last run, sort, export CSV/XLSX/JSON. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/dataset-transform-pro.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.19 / 1,000 output rows

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 Transform Pro merges your Apify datasets and CSV, JSON, Excel or Google Sheets files, then filters, flattens, renames, removes duplicates (exact or fuzzy), explodes arrays, keeps only rows that are new since the last run and sorts them — all in one run.**

- **One run instead of a chain:** read and merge, filter, transform, dedupe, explode, only new, sort, max rows, write. No glue between five Actors.
- **Any source:** Apify datasets plus public file links (CSV, TSV, JSON, NDJSON, Excel XLSX, and Google Sheets links shared as "Anyone with the link").
- **Only new rows:** remembers what earlier runs wrote, so a scheduled scraper + this Actor gives you (and bills you for) only new listings, jobs or products.
- **Fuzzy dedupe:** `Acme Inc.` = `ACME, Inc`, `12 Main St.` = `12 Main Street`, `(555) 010-2000` = `+1 555 010 2000`.
- **Download link:** optional CSV, Excel XLSX or JSON file next to the dataset.

**Price: $1.70 per 1,000 output rows.** Only rows written to the output dataset are charged. Reading, filtering, and every row removed by a step are free.

**Try it free:** leave the input empty and press **Start**. The demo merges two small sample shop lists, drops the out-of-stock item and the duplicate, explodes the colors and sorts by price — 5 rows in seconds, not charged (rows carry `_demo: true`).

| sku | name | price | country | color | \_source |
|---|---|---|---|---|---|
| TPT-04 | Glass Teapot | 31 | JP | clear | demo-shop-b |
| TPT-04 | Glass Teapot | 31 | JP | smoke | demo-shop-b |
| MUG-01 | Ceramic Mug | 12.5 | US | white | demo-shop-a |
| MUG-01 | Ceramic Mug | 12.5 | US | blue | demo-shop-a |
| SPN-03 | Teak Spoon | 6.9 | DE | natural | demo-shop-a |

*(output of the free demo; the `_demo` column is left out here)*

Need only flattening, column picking and a CSV of one dataset? The simpler [Dataset Transform](https://apify.com/ucchiii/dataset-transform) from the same developer does that for less ($0.65 per 1,000 rows). This Pro version adds merging datasets and files, Excel and Google Sheets input, dedupe, explode, only-new-rows memory and XLSX export.

### How to use

1. Add **Datasets** (the `defaultDatasetId` of your scraper runs, or a dataset URL) and/or **File URLs**.
2. Turn on the steps you need. Every step is optional; an empty step does nothing.
3. Press **Start**. Rows go to the run's dataset; with **Also save a file**, the download link is in the `STATS` record (`fileUrl`) and the status message names the file.

### Step order

Steps always run in this order:

1. **Read and merge** all datasets, then all files, in the order given (optional `_source` column)
2. **Filter** (`price > 100`, `country in US,CA`, `email is not empty` …, all or any)
3. **Transform**: flatten nested JSON, convert types, keep / remove / rename columns
4. **Remove duplicates** by columns, exact or fuzzy, keep the first or last row
5. **Explode** one array column into one row per element
6. **Only new rows**: drop rows written by earlier runs with the same state name
7. **Sort**, then **max output rows**
8. **Write** the dataset (charged per row) and the optional file

Column names: **filters** use the original names (nested: `address.city`). **Keep / remove / rename / convert** use the flattened names before renaming, as in Dataset Transform. **Dedupe, explode, only new and sort** use the output names (after renaming).

### Examples

**Merge two scraper runs and a CSV, one row per URL, Excel file:**

```json
{
  "datasetIds": ["WkzbQMuFYuamGv3YF", "Hx2Pq8ZfLmR4tN1aB"],
  "fileUrls": ["https://<your-public-host>/old-leads.csv"],
  "addSourceColumn": true,
  "dedupeBy": ["url"],
  "dedupeKeep": "last",
  "exportFormat": "xlsx"
}
```

**Only new job postings since the last run (schedule it after your scraper):**

```json
{
  "datasetIds": ["WkzbQMuFYuamGv3YF"],
  "filters": ["location contains Berlin"],
  "select": ["title", "company.name", "url", "postedAt"],
  "rename": {"company.name": "company"},
  "onlyNew": true,
  "onlyNewFields": ["url"],
  "stateName": "jobs-berlin",
  "sortBy": "postedAt",
  "sortDesc": true
}
```

**Clean a lead list: keep rows with a phone, merge near-duplicate companies:**

```json
{
  "datasetIds": ["WkzbQMuFYuamGv3YF"],
  "filters": ["phone is not empty"],
  "rename": {"title": "company"},
  "dedupeBy": ["company", "address", "phone"],
  "dedupeMode": "fuzzy",
  "exportFormat": "csv"
}
```

**One row per review from nested product data:**

```json
{
  "datasetIds": ["WkzbQMuFYuamGv3YF"],
  "select": ["title", "price", "reviews"],
  "coerce": {"price": "number"},
  "explodeField": "reviews"
}
```

Each review becomes a row with `reviews.text`, `reviews.rating` … and the product's `title` and `price` copied.

**A Google Sheet:** paste its link (shared as "Anyone with the link can view") into **File URLs**; the tab in the link is read as CSV.

### Output

- **Dataset**: the rows left after all steps. Download as CSV, Excel, JSON and more with Apify's export buttons or the API.
- **File** (optional): `<fileName>.csv`, `.xlsx` or `.json` in the run's key-value store; the signed link is `fileUrl` in `STATS`.
- **STATS** (key-value store): what each step did, for example

```json
{
  "rowsRead": 12034, "rowsFilteredOut": 9120, "duplicatesRemoved": 310, "rowsAfterExplode": 4022,
  "rowsSeenBefore": 3870, "rowsWritten": 152, "chargedRows": 152, "stoppedAtChargeLimit": false,
  "fileKey": "export.xlsx", "fileUrl": "https://api.apify.com/v2/key-value-stores/…/records/export.xlsx?signature=…"
}
```

### Only new rows: how the memory works

- Each run with **Only rows not output before** saves a short fingerprint of every row it wrote, in a key-value store named `dataset-transform-pro-state` in your own Apify account (record `SEEN-<state name>`).
- A row is "the same" when the **Columns that identify a row** match (for example `url`); with no columns, when the whole row matches (the `_source` column is ignored).
- The first run outputs everything. Rows not written (cut by max rows or by your maximum cost per run) are not remembered and count as new next time.
- Use a different **State name** for each scheduled job. Delete the record (or use a new name) to start over.

### Pricing

| Event | Price |
|---|---|
| Output row (one row written to the output dataset after all steps) | $1.70 per 1,000 |

Reading, filtering, dedupe, explode bookkeeping and rows removed by any step are free; the demo is free; the file export costs nothing extra.
Set **Max output rows** or a maximum cost per run to cap spend: the Actor stops cleanly at the limit, and if the limit is below the price of one row it stops before reading anything.
On the Apify Free plan, the $5 of monthly platform credit covers about **3,800 output rows** a month.

### Limits (cannot be raised by input)

- 20 sources per run (datasets and files together); files up to 100 MB (JSON arrays up to 50 MB); Excel: first sheet only, `.xlsx` (not old `.xls`)
- 500,000 rows after filtering (all rows are held in memory for dedupe and sorting); add filters or split larger jobs
- 1,000,000 output rows per run (also after exploding), 1,000 columns per row, text cells cut at 32,000 characters
- Fuzzy dedupe: up to 200,000 rows
- Only new rows: the newest 300,000 fingerprints per state name are kept
- Files: up to 150 MB; Excel files up to 1,048,575 rows (the dataset always has every row)
- Only public file links (no logins, no API keys); internal network addresses are blocked

### FAQ

**Does it change my datasets?** No. It only reads them and writes a new dataset.
**Why are my CSV numbers text?** CSV cells are text. Sorting already treats number-like text as numbers; to get real numbers in the output add `{"price": "number"}` to **Convert column types**.
**How does fuzzy dedupe decide?** Each column is compared by its name: name/company/title ignore legal forms (Inc, LLC, GmbH, 株式会社) and punctuation; address expands street abbreviations; phone compares digits; url/website/email compare the domain; anything else is plain fuzzy text. With two or more columns, at least two must agree (or a phone or URL). Raise or lower **Fuzzy match threshold** (default 0.9) to be stricter or looser.
**Which row is kept from duplicates?** The first by default (sources are read in the order given), or the last with **Keep: last**.
**Is the file link private?** Anyone holding the signed link can download the file; it gives no access to anything else in your account.
**What does it cost in practice?** A run that reads 50,000 rows and writes 2,000 new ones costs $2.60. Rows that are filtered out, duplicated or seen before cost nothing.

### Use it from the API, Make, n8n or an AI agent (MCP)

Run it and get the output rows back in one HTTP call (replace `<YOUR_TOKEN>` with your Apify API token):

```bash
curl -X POST "https://api.apify.com/v2/acts/ucchiii~dataset-transform-pro/run-sync-get-dataset-items?token=<YOUR_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"datasetIds": ["WkzbQMuFYuamGv3YF"], "filters": ["rating >= 4.5"], "dedupeBy": ["url"], "onlyNew": true, "onlyNewFields": ["url"], "maxRows": 500}'
```

The response holds the rows; the file link is in the run's `STATS` record (`fileUrl`).

- **Make, n8n, Zapier:** use the Apify app / node, pick this Actor and pass the same JSON input. Schedule it after your scraper with "Only new rows" for a feed of new items.
- **AI agents (Claude, Cursor and other MCP clients):** add `https://mcp.apify.com?tools=ucchiii/dataset-transform-pro` to your MCP settings.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [Dataset Transform](https://apify.com/ucchiii/dataset-transform) — flatten, filter, rename and convert any Apify dataset, export CSV / JSON / JSONL with a link
- [Filter CSV, JSON or Dataset Rows by Condition](https://apify.com/ucchiii/filter-rows) — keep only the rows of a CSV, JSON file or dataset that match simple conditions like country = US or price > 100
- [Merge Datasets](https://apify.com/ucchiii/merge-datasets) — combine several datasets or CSV/JSON files into one, with columns aligned
- [Remove Duplicates](https://apify.com/ucchiii/dataset-dedup-merge) — merge Apify datasets and remove duplicates by the fields you choose
- [Dataset Change Detector](https://apify.com/ucchiii/dataset-change-detector) — compare two runs of any scraper: only added, removed and changed items

# Actor input Schema

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

Apify datasets to read, in order (e.g. the defaultDatasetId of finished scraper runs). You can paste dataset URLs from Apify Console too. Up to 20 sources per run (datasets and files together). Leave datasets AND file URLs empty for a free demo on sample data (not charged).

## `fileUrls` (type: `array`):

Public http(s) links to files, read after the datasets. CSV, TSV, JSON (array), NDJSON and Excel XLSX (first sheet). A Google Sheets link shared as 'Anyone with the link' is read as CSV (the tab in the link). Each file up to 100 MB (JSON arrays up to 50 MB).

## `addSourceColumn` (type: `boolean`):

Add a '\_source' column (last column) with the dataset ID or file URL each row came from. Filters can use it too.

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

Keep only rows that match. One condition per line: column, operator, value. Operators: = != > >= < <= contains, not contains, starts with, ends with, in (comma list), not in, is empty, is not empty. Text is compared without case, numbers as numbers, ISO dates work with > and <. Column names are the ORIGINAL names (nested: address.city). Through the API you can also pass objects like {"field": "price", "op": "gt", "value": 10}.

## `filterMode` (type: `string`):

Whether a row must match all filters or just one.

## `select` (type: `array`):

Columns to output, in this order. Use the flattened name, e.g. 'address.city'. A parent name such as 'address' keeps all columns under it. Empty = all columns.

## `omit` (type: `array`):

Columns to drop. A parent name such as 'meta' removes everything under it. Applied after 'Keep only these columns'.

## `rename` (type: `object`):

Map of flattened column name to new name, e.g. {"address.city": "city"}. Two columns cannot share a new name. Later steps (dedupe, explode, only new, sort) use the NEW names.

## `coerce` (type: `object`):

Map of flattened column name to type: string, number, integer, boolean or date. Example: {"price": "number", "createdAt": "date"}. Numbers accept '$1,234.50'; dates become ISO 8601 UTC. Values that cannot be converted become empty and are counted in STATS.

## `maxDepth` (type: `integer`):

How many levels of nested objects to flatten into dot-path columns (address.geo.lat). 0 = do not flatten. Default 10.

## `arrayMode` (type: `string`):

How arrays become columns (the explode column is never changed by this). Default: json.

## `arrayJoinSeparator` (type: `string`):

Text between values when Arrays = join. Default '; '.

## `flattenSeparator` (type: `string`):

Character(s) that join nested names in flattened columns ('.' gives address.city). Column names in other settings must use the same separator. Max 5 characters.

## `trimStrings` (type: `boolean`):

Remove leading and trailing spaces from all text values.

## `dedupeBy` (type: `array`):

Columns that identify a duplicate (output names, after renaming), e.g. url, or name + city. '\*' = rows identical in every column. Empty = no dedupe. Text is compared ignoring case and extra spaces.

## `dedupeMode` (type: `string`):

Fuzzy compares each column by its name: *name/company/title* ignore legal forms and punctuation, *address* expands street abbreviations, *phone* compares digits, *url/website/email* the domain; others as plain text. With 2+ columns, at least two must agree (or a phone / url). Up to 200,000 rows.

## `dedupeKeep` (type: `string`):

Which row of a duplicate group stays. 'last' is handy when later sources hold fresher data.

## `fuzzyThreshold` (type: `number`):

Only for fuzzy: minimum similarity for two rows to count as the same. Lower finds more (and riskier) matches. Default 0.9.

## `explodeField` (type: `string`):

Column with an array (output name, after renaming), e.g. 'tags' or 'reviews'. Each element becomes its own row with the other columns copied; object elements become columns like reviews.text. A JSON array written as text also works. Empty or missing arrays keep one row.

## `explodeSeparator` (type: `string`):

Optional: also explode plain text values split by this separator, e.g. ';' turns 'red; blue' into two rows. Useful for CSV files.

## `onlyNew` (type: `boolean`):

Remember the rows each run writes (in a key-value store named 'dataset-transform-pro-state' in your account) and output only rows not written by earlier runs with the same state name. The first run outputs everything. Rows cut by max rows or the cost limit are not remembered.

## `onlyNewFields` (type: `array`):

For 'only new rows': columns that make a row the same as before (output names), e.g. url or id. Empty = the whole row (any changed value counts as new).

## `stateName` (type: `string`):

Separate memory for each scheduled job, e.g. 'jobs-berlin'. Letters, digits, dot, dash and underscore. A new name starts from scratch.

## `sortBy` (type: `string`):

Column to sort by (output name). Numbers (also numbers written as text, e.g. from CSV) sort before text; empty values always go last. Empty = keep the order.

## `sortDesc` (type: `boolean`):

High to low / Z to A.

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

Write at most this many rows (after sorting). Empty = no limit (hard cap 1,000,000). Billing is per output row, so this also caps cost.

## `exportFormat` (type: `string`):

Besides the dataset, save the output rows as a file in the run's key-value store, with a download link in the STATS record (fileUrl). Up to 150 MB. Not charged extra.

## `fileName` (type: `string`):

File name without extension. Only letters, digits, dot, dash and underscore are kept.

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/attention.csv"
  ],
  "addSourceColumn": false,
  "filters": [
    "attention = focused"
  ],
  "filterMode": "all",
  "maxDepth": 10,
  "arrayMode": "json",
  "arrayJoinSeparator": "; ",
  "flattenSeparator": ".",
  "trimStrings": false,
  "dedupeBy": [
    "subject"
  ],
  "dedupeMode": "exact",
  "dedupeKeep": "first",
  "fuzzyThreshold": 0.9,
  "onlyNew": false,
  "stateName": "default",
  "sortBy": "score",
  "sortDesc": false,
  "exportFormat": "none",
  "fileName": "export"
}
```

# Actor output Schema

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

The rows left after all steps (merged, filtered, transformed, deduplicated, exploded, only new, sorted) in the default dataset. Download as CSV, JSON, Excel and more from here.

## `stats` (type: `string`):

Record STATS: rows read, filtered out, duplicates removed, exploded, seen before, written, and the link (fileUrl) to the saved CSV / XLSX / JSON file.

# 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 = {
    "fileUrls": [
        "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/attention.csv"
    ],
    "filters": [
        "attention = focused"
    ],
    "dedupeBy": [
        "subject"
    ],
    "sortBy": "score"
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/dataset-transform-pro").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 = {
    "fileUrls": ["https://raw.githubusercontent.com/mwaskom/seaborn-data/master/attention.csv"],
    "filters": ["attention = focused"],
    "dedupeBy": ["subject"],
    "sortBy": "score",
}

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/dataset-transform-pro").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 '{
  "fileUrls": [
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/attention.csv"
  ],
  "filters": [
    "attention = focused"
  ],
  "dedupeBy": [
    "subject"
  ],
  "sortBy": "score"
}' |
apify call ucchiii/dataset-transform-pro --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/dataset-transform-pro"
        }
    }
}
```

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/sLWWwjSBzVC9NTNc4/builds/FerkeiQblLj8LDE3Z/openapi.json
