# Dataset Toolkit: Merge, Dedupe, Diff & Export to Excel/CSV (`latamdatatools/dataset-toolkit`) Actor

Merge or join Apify datasets and CSV/JSON/Excel files, deduplicate, filter, rename fields, normalize emails, phones (E.164) and URLs, compare with a previous run (added / changed / removed) and export to XLSX, CSV, JSONL or JSON.

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

## Pricing

from $0.30 / 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.

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 Toolkit: Merge, Dedupe, Diff & Export to Excel/CSV

The Swiss army knife for the data your Actors produce. Take one or more **Apify datasets** and/or **CSV, TSV, JSON, JSONL or Excel files** and in one run:

1. **Append or join** them (like VLOOKUP / SQL left join on key fields).
2. **Rename, select or drop** fields (nested fields with dot notation).
3. **Normalize** emails, phone numbers (E.164 with libphonenumber), URLs (https, lower-case host, no utm/gclid/fbclid, no trailing slash) and text.
4. **Filter** with simple conditions (equals, contains, empty, greater than, in list, regex...).
5. **Deduplicate** by one or several fields: keep first, last, most complete, or **merge** duplicates into one row.
6. **Diff against a previous run**: every row tagged `added`, `changed` (with the changed fields and their old values) or `removed`. Perfect for "what is new since yesterday" on any scraper.
7. **Sort** and **export** to **XLSX, CSV (comma/semicolon/tab), JSONL or JSON**, plus the cleaned rows in the dataset.

### What does Dataset Toolkit do?

Dataset Toolkit merges and joins Apify datasets and CSV, JSON or Excel files, removes duplicates, filters rows, renames fields, normalizes emails, phone numbers (E.164) and URLs, compares with a previous run (added / changed / removed) and exports to XLSX, CSV, JSONL or JSON.

### How to use Dataset Toolkit

1. Click **Try for free** on this page (a free Apify account is enough to start).
2. Fill in the input (see the examples below) or keep the prefilled example.
3. Click **Start** and wait for the run to finish.
4. Download the results from the **Output** tab as JSON, CSV, Excel or HTML, or read them with the Apify API.
5. Optional: create a **Schedule** to run it daily or weekly, and connect a webhook or an integration (Make, Zapier, n8n, Slack).

### Who uses it

- **Apify users who chain Actors**: clean and merge the output of several scrapers before sending it to a CRM or a sheet.
- **Lead generation**: dedupe leads by email or domain, normalize phones, join enrichment data.
- **Price and catalog monitoring**: diff today's scrape against yesterday's and keep only the changes.
- **Analysts**: convert JSON datasets to a clean Excel file with frozen headers and filters.

### Input example: clean and dedupe leads, keep only what changed

```json
{
  "datasetIds": ["aBcD1234EfGh5678i"],
  "fileUrls": ["https://docs.google.com/spreadsheets/d/<id>/edit#gid=0"],
  "normalizeEmails": ["email"],
  "normalizePhones": ["phone"],
  "phoneCountry": "US",
  "normalizeUrls": ["website"],
  "filters": [{ "field": "email", "op": "notEmpty" }],
  "dedupeFields": ["email"],
  "dedupeKeep": "merge",
  "diffDatasetId": "PrEvIoUsRuNdAtAsEt",
  "diffKeys": ["email"],
  "diffIgnoreFields": ["scrapedAt"],
  "outputFormats": ["xlsx", "csv"],
  "fileName": "leads-clean"
}
```

### Output

Each output row is your record after the operations, plus helper fields when they apply:

```json
{
  "company": "Acme",
  "email": "sales@acme.com",
  "phone": "+12025550143",
  "website": "https://www.acme.com",
  "_diff": "changed",
  "_diffChangedFields": ["employees"],
  "_diffPrevious": { "employees": 40 },
  "_invalidFields": ["phone"]
}
```

- `_diff`, `_diffChangedFields`, `_diffPrevious`: only when you compare with a previous version.
- `_invalidFields`: values that could not be normalized (kept, emptied or row removed, as you choose).
- `_source`: the dataset / file a row came from (optional).

Export files are saved in the run's key-value store; their download links are in `RUN_SUMMARY` (Output tab), with counts of duplicates, filtered rows, invalid values and diff results.

### Pricing

Pay per event:

- **USD 0.30 per 1,000 output rows** (`row`): rows that end up in the result (dataset and/or files). Filtered-out rows and removed duplicates are free.
- **USD 0.01 per export file** (`file`).
- Start: USD 0.00005.

Cleaning 10,000 rows and exporting an Excel file costs about USD 3.01. The Actor never outputs more rows than your max charge per run allows.

### Notes and limits

- Up to 2,000,000 rows read per run (default 500,000; use more memory for very large data, roughly 1 GB per 300,000 average rows).
- Files up to 100 MB each; Excel files keep up to 1,048,575 rows (Excel's own limit; CSV/JSONL keep all).
- CSV delimiter and encoding (UTF-8, with or without BOM) are detected; the first row must be the header.
- Phone normalization needs a default country for numbers written without `+country`.
- Diff compares field values exactly after normalization; use "Ignore these fields" for timestamps.

### Cost examples

Prices at the current pay-per-event rate: USD 0.00005 per run, USD 0.30 per 1,000 output rows and USD 0.01 per export file (filtered-out rows and removed duplicates are free). You can set a maximum charge per run in the run options.

| Job | Approximate cost |
|---|---|
| Test run: 249-row CSV to Excel (measured: 249 rows + 1 XLSX file, 5 s) | about $0.085 |
| Merge 3 lead lists, 1,000 rows left after dedupe, Excel + CSV | about $0.32 |
| Clean 10,000 rows and export an Excel file | about $3.01 |
| Weekly diff that outputs only ~200 changed rows | about $0.07 per run |

### Use it from your code, an integration or an AI agent

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("latamdatatools/dataset-toolkit").call(run_input={
  "datasetIds": [
    "<DATASET_ID>"
  ],
  "normalizeEmails": [
    "email"
  ],
  "dedupeFields": [
    "email"
  ],
  "dedupeKeep": "merge",
  "outputFormats": [
    "xlsx"
  ]
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**JavaScript / Node.js** (`npm install apify-client`):

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('latamdatatools/dataset-toolkit').call({
  datasetIds: [
    '<DATASET_ID>'
  ],
  normalizeEmails: [
    'email'
  ],
  dedupeFields: [
    'email'
  ],
  dedupeKeep: 'merge',
  outputFormats: [
    'xlsx'
  ]
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length, items[0]);
```

**No code:**

- **Schedules:** save your input as a Task and run it after each scraping run or weekly from Apify Console (Schedules).
- **Integrations:** send the results to Google Sheets, Slack, email, Make, Zapier, n8n or Airbyte from the Integrations tab, or call your own webhook when a run finishes.
- **AI agents:** add it as a tool in Claude, Cursor, VS Code and other MCP clients through the Apify MCP server (`https://mcp.apify.com`), so the agent can merge, clean and export the results of other Actors.

### FAQ

**Can I call it from my own code or from an AI agent?** Yes. Start runs and fetch results with the Apify API or the JavaScript / Python clients, or use it as a tool from Claude, Cursor and other MCP clients through the Apify MCP server (`mcp.apify.com`).

**Can I run it automatically?** Yes. Create a Schedule in Apify Console (for example every morning) and add a webhook or an integration to get the results where you need them.

**Which export formats are available?** JSON, JSONL, CSV, Excel (XLSX), XML, RSS and HTML table, from the Output tab or the API.

**What does it cost?** See the Pricing section above. You only pay for the events listed there.

### Changelog

- 0.1 (2026-10): first version.

# Actor input Schema

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

Pick one or more datasets (or paste their IDs) from any Actor run. Several datasets are appended or joined.

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

Public file URLs, up to 100 MB each. Format is detected automatically. Google Sheets links work if shared as "Anyone with the link".

## `mergeMode` (type: `string`):

Append = stack all rows. Join = enrich the first source with the fields of the others, matching on key fields (like a VLOOKUP / SQL join).

## `joinKeys` (type: `array`):

Fields that identify the same record, e.g. domain or email (case-insensitive).

## `joinKeysRight` (type: `array`):

Optional, same order as above, e.g. website_domain.

## `joinType` (type: `string`):

Left = keep every row of the first source. Inner = only rows found in both.

## `joinPrefix` (type: `string`):

Optional, e.g. crm\_ to tell joined fields apart.

## `addSourceField` (type: `boolean`):

Each row gets the dataset ID / file URL it came from (append mode).

## `selectFields` (type: `array`):

Optional. Dot notation for nested fields (address.city). Order is kept in the output.

## `renameFields` (type: `object`):

JSON map old name -> new name, e.g. {"Email Address": "email", "company.name": "company"}. Applied before selecting.

## `dropFields` (type: `array`):

Optional.

## `trimText` (type: `boolean`):

Removes leading/trailing spaces and double spaces in every top-level text field.

## `normalizeEmails` (type: `array`):

Lower-case, trimmed, "Name <email>" and mailto: cleaned.

## `normalizePhones` (type: `array`):

Converted to +CountryNumber (e.g. +12025550143) with libphonenumber.

## `phoneCountry` (type: `string`):

Two-letter code for numbers without +country (US, GB, AR, BR, ES...).

## `normalizeUrls` (type: `array`):

Adds https://, lower-cases the host, removes tracking parameters (utm\_\*, gclid, fbclid...), fragments and trailing slashes.

## `stripWww` (type: `boolean`):

Useful to dedupe websites.

## `lowercaseFields` (type: `array`):

Optional.

## `invalidValues` (type: `string`):

Keep the original value, empty it, or remove the row.

## `flagInvalid` (type: `boolean`):

Adds \_invalidFields with the names of the fields that could not be normalized.

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

JSON list of conditions, e.g. \[{"field": "country", "op": "eq", "value": "US"}, {"field": "employees", "op": "gte", "value": 10}]. Operators: eq, neq, contains, notContains, startsWith, endsWith, empty, notEmpty, gt, gte, lt, lte, in (comma list), regex. Text comparisons ignore case.

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

All conditions must match, or any of them.

## `dedupeFields` (type: `array`):

Rows with the same values in these fields are duplicates (after normalization), e.g. email, or domain + country.

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

Merge = keep the first row and fill its empty fields from the duplicates.

## `dedupeCaseSensitive` (type: `boolean`):

Off = Apple and apple are the same value.

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

Optional. Numbers and text are sorted naturally.

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

Largest / latest first.

## `diffDatasetId` (type: `string`):

Dataset ID of an earlier run (e.g. yesterday's scrape). Each row gets \_diff = added / changed / removed / unchanged, with the changed fields and their previous values.

## `diffFileUrl` (type: `string`):

CSV / JSON / JSONL / XLSX of the previous version.

## `diffKeys` (type: `array`):

What identifies the same record in both versions, e.g. url, id or sku. Defaults to the dedupe fields.

## `diffIgnoreFields` (type: `array`):

e.g. scrapedAt, timestamps or rankings that always change.

## `diffOutput` (type: `string`):

Which rows to output.

## `outputDataset` (type: `boolean`):

Off = only the export files.

## `outputFormats` (type: `array`):

Files saved in the run's key-value store, with download links in RUN_SUMMARY and the Output tab. Nested fields are flattened with dots for XLSX and CSV.

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

Base name of the export files.

## `csvDelimiter` (type: `string`):

Semicolon is handy for Excel in many European / Latin American locales.

## `arraysInFiles` (type: `string`):

How list fields are written in flat files.

## `inferTypes` (type: `boolean`):

"42" becomes 42 and "true" becomes true (values with leading zeros stay text).

## `sheetName` (type: `string`):

Optional; default is the first sheet.

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

Upper limit of rows read from the sources (up to 2,000,000; large runs need more memory). Your max charge per run is respected too.

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/datasets/country-codes/main/data/country-codes.csv"
  ],
  "mergeMode": "append",
  "joinType": "left",
  "addSourceField": false,
  "trimText": true,
  "stripWww": false,
  "invalidValues": "keep",
  "flagInvalid": true,
  "filterMode": "all",
  "dedupeKeep": "first",
  "dedupeCaseSensitive": false,
  "sortDesc": false,
  "diffOutput": "changes",
  "outputDataset": true,
  "outputFormats": [
    "xlsx"
  ],
  "fileName": "dataset",
  "csvDelimiter": ",",
  "arraysInFiles": "join",
  "inferTypes": true,
  "maxRows": 500000
}
```

# Actor output Schema

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

No description

## `files` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# 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/datasets/country-codes/main/data/country-codes.csv"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("latamdatatools/dataset-toolkit").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/datasets/country-codes/main/data/country-codes.csv"] }

# Run the Actor and wait for it to finish
run = client.actor("latamdatatools/dataset-toolkit").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/datasets/country-codes/main/data/country-codes.csv"
  ]
}' |
apify call latamdatatools/dataset-toolkit --silent --output-dataset

```

## MCP server setup

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

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/jxnXJHhRaOd8Fj2FJ/builds/wsj76TU1e9B5K7qzC/openapi.json
