# Dataset Stream Transform — Merge, Deduplicate, Filter Big CSV (`northbell/dataset-stream-transform`) Actor

Merge, filter, dedupe, rename and export CSV, TSV, JSON, JSONL and XLSX files or Apify datasets. It streams: a million-row input runs in 1-2 GB without crashing, and you pay only for the rows you keep.

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

## Pricing

from $0.24 / 1,000 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 Stream Transform — Merge, Deduplicate, Filter and Export Big CSV, JSON, XLSX Files and Datasets

**Filter, dedupe, rename and export tabular data from files or Apify datasets.** It streams: a million-row CSV or dataset runs in 1–2 GB without crashing, and you pay only for the rows you keep. $0.30 per 1,000 kept rows. Rows dropped by a filter, as duplicates, or as already seen are free.

**Try it now — the input is already filled in.** Press **Start**: it streams the public-domain OurAirports list (86,343 rows, 8.8 MB CSV), keeps the large airports in Japan and drops a second airport in the same city — 29 rows match, 28 are kept (about $0.01). Then put your own CSV, TSV, JSON, JSONL or XLSX URL (or an Apify dataset ID) in **Sources**.

It can also run automatically after your scraper: see "Run it after your scraper" below.

Two of the 28 rows from our own run of exactly this input on Apify (21 Nov 2026, 4 seconds):

```json
{ "ident": "RJAA", "type": "large_airport", "name": "Narita International Airport", "elevation_ft": "141", "continent": "AS", "iso_country": "JP", "iso_region": "JP-12", "municipality": "Narita", "icao_code": "RJAA", "iata_code": "NRT", "gps_code": "RJAA", "local_code": "", "coordinates": "35.76858, 140.388714" }
{ "ident": "RJAH", "type": "large_airport", "name": "Ibaraki Airport", "elevation_ft": "105", "continent": "AS", "iso_country": "JP", "iso_region": "JP-08", "municipality": "Omitama", "icao_code": "RJAH", "iata_code": "IBR", "gps_code": "RJAH", "local_code": "", "coordinates": "36.181456, 140.414434" }
```

And its `OUTPUT` summary in the key-value store:

```json
{
  "read": 86343,
  "kept": 28,
  "droppedByFilter": 86314,
  "droppedDuplicates": 1,
  "droppedSeen": 0,
  "sources": [{ "source": "https://raw.githubusercontent.com/datasets/airport-codes/main/data/airport-codes.csv", "read": 86343, "kept": 28, "error": null }],
  "seconds": 0.7,
  "peakRssMb": 123,
  "stoppedBy": null,
  "exportCsvUrl": null
}
```

For your own file: `{ "sources": ["<your CSV link>"], "filters": [{ "field": "country", "op": "eq", "value": "JP" }], "dedupeBy": ["email"], "exportCsv": true }`.

**Measured:** 1,000,000 rows (143 MB CSV, about 10% repeated keys, some in full-width), filter `country = JP` (20% of rows), `dedupeBy` email, CSV export on: kept 179,002, dropped 800,000 by the filter and 20,998 as duplicates. Peak memory 282 MB. Run time 537 seconds on a Windows PC, almost all of it spent by the local test storage writing 179,002 separate files; a second run on the same file that kept nothing (so it only read, filtered and checked 1,000,000 rows) took 7.2 seconds at 248 MB. On Apify, the 86,343-row sample above was read and filtered in 0.7 seconds at a 123 MB peak.

### Why it does not crash on big input

Most converters load the whole file, then work on it. This one reads a file line by line (an Apify dataset page by page, 1,000 items at a time), pushes kept rows in batches of 500, and never keeps the rows. The only thing it holds in memory for the whole run is a short hash of each dedupe key, about 40 bytes per kept row when you dedupe, and nothing when you do not. Ten million distinct keys need roughly 400 MB.

### Input

| Field | What it does |
|---|---|
| `sources` | Required. Apify dataset IDs, or URLs of CSV, TSV, JSON (one array), JSONL/NDJSON or XLSX files. Read one after another. Dedupe works across all of them. |
| `format` | `auto` (default): from the file extension, then the content type, then the first character. Set it when the URL has no useful extension. |
| `filters` | List of `{field, op, value}`. See the table below. Empty: keep every row. |
| `filterMode` | `all` (default): a row must pass every filter. `any`: at least one. |
| `dedupeBy` | Field names. Rows with the same values are duplicates; the first is kept. Empty: no dedupe. |
| `normalizeForDedupe` | Default on. See "Dedupe". |
| `select` | Fields to keep, in this order. Empty: all fields. |
| `rename` | Old name to new name. Applied after `select`. |
| `flatten` | Default off. On: `{"a": {"b": 1}}` becomes `{"a.b": 1}`. |
| `onlyNewSinceLastRun` | Default off. Needs `dedupeBy`. Drops rows whose key an earlier run already returned to you; they are not charged. |
| `exportCsv` | Default off. Also writes the kept rows to `EXPORT.csv` in the key-value store; the link is in `OUTPUT`. |
| `maxRows` | Stop after this many kept rows. 0: no limit. |

Order of work for each row: filter, dedupe, already-seen check, row limit and charge budget, then flatten, select and rename. A row dropped by a filter is never remembered as a key.

### Filter ops

| Op | Keeps the row when |
|---|---|
| `eq`, `ne` | The value equals (or differs from) `value`. Text is compared after Unicode NFKC, trimmed, case-insensitive. |
| `contains`, `notContains` | The text contains `value` (same normalization). |
| `regex` | The text matches. `value` is a pattern, or `/pattern/flags` such as `/^tokyo/i`. |
| `gt`, `gte`, `lt`, `lte` | Numeric comparison when `value` is a number (commas ignored); otherwise text comparison. A row that is empty or not a number is dropped. |
| `in`, `notIn` | The value is one of the listed values. `value` is a list or a comma-separated string. |
| `isEmpty`, `notEmpty` | The field is missing, null, blank or an empty list (or not). |
| `before`, `after` | The field is a date earlier (or later) than `value`, such as `2026-11-20`. A row whose field is not a date is dropped. |

Field names can be nested: `address.city`. A bad filter (unknown op, broken regex, `before` with a non-date) stops the run at the start, before anything is charged.

### Dedupe

With `normalizeForDedupe` on, each key value is made comparable before it is hashed: Unicode NFKC (full-width and half-width forms match, so `ＡＢＣ` equals `abc`, and half-width katakana equals full-width), trimmed, lower case, repeated spaces collapsed. A value that starts with `http://`, `https://` or `www.` also loses its query string, fragment and trailing slash, so `https://x.com/a/?utm=1` equals `https://x.com/a`. Hiragana and katakana are not treated as the same.

A row whose key fields are all empty has no identity: it is kept and never counted as a duplicate. The key is stored as a 52-bit hash; for ten million distinct keys the chance of one false duplicate in a run is about 1 in 100.

### Only new since last run

For a schedule that reads the same source every day. The Actor keeps a named key-value store (`dataset-stream-transform-seen`) with the hashes of the dedupe keys it returned, newest 5,000,000 at most. If that store cannot be opened the run stops before charging. Rows that were cut off by a charge limit or a time limit are not saved as seen, so the next run returns them.

### Run it after your scraper

In Apify Console, open your scraper's **Integrations**, add **Run Actor**, pick this Actor and give it an input such as:

```json
{
  "sources": ["{{resource.defaultDatasetId}}"],
  "filters": [{ "field": "email", "op": "notEmpty" }],
  "dedupeBy": ["email"],
  "onlyNewSinceLastRun": true,
  "exportCsv": true
}
```

Each scraper run then hands its dataset over: you get only the rows that pass your filters and that you have not had before, and you pay only for those. A daily schedule works the same way with a fixed dataset ID or file URL.

### Output and price

- Kept rows go to the default dataset. `OUTPUT` in the key-value store holds the summary: `read`, `kept`, `droppedByFilter`, `droppedDuplicates`, `droppedSeen`, per-source `read`, `kept` and `error`, `seconds`, `peakRssMb`.
- Charge: event `row-kept` per row pushed, $0.0003 ($0.30 per 1,000). The batch is pushed first, then charged. The Actor respects your maximum total charge for the run and stops cleanly when it is reached.

### Limits

- XLSX: first sheet only; row 1 is the header. The file is saved to the run's disk first, then the sheet is read row by row.
- JSON must be one array of objects. For anything else use JSONL.
- CSV and TSV: UTF-8, header row required, values stay text. In the CSV export, the columns are those of the first 500 kept rows (or your `select`); a key that appears only later is left out of the CSV (the dataset has it). Nested values are written as JSON text.
- A source that cannot be read (bad URL, 404) is reported with an `error` in the summary and the run goes on with the next source. The run fails only if no source could be read at all.
- The Actor stops 30 seconds before the run's time limit; everything charged is already in the dataset.
- Files are fetched over HTTP(S) from public URLs. Compressed files (.gz, .zip) are not unpacked.

### 日本語の説明

CSV・TSV・JSON・JSONL・XLSX のファイル、または Apify のデータセットを、ストリームで（全部をメモリに載せずに）絞り込み・重複除去・列の整理・CSV 出力する Actor です。100万行規模でも 1〜2 GB で動きます。課金は残した行だけ（1,000行あたり 0.30 ドル）で、絞り込みや重複で落とした行は無料です。重複判定では全角・半角を同じものとして扱い（ＡＢＣ と abc、半角カナと全角カナ）、URL は末尾のスラッシュとクエリを無視します。「前回以降の新規のみ」を使うと、毎日同じ元データを読む定期実行で、すでに返した行を除けます。

# Actor input Schema

## `sources` (type: `array`):

Apify dataset IDs, or URLs of CSV, TSV, JSON (array), JSONL/NDJSON or XLSX files. Several sources are read one after another and deduplicated together.

## `format` (type: `string`):

Only needed when a URL has no useful file extension or content type. Dataset IDs ignore this.

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

A list of {"field": "country", "op": "eq", "value": "JP"}. Ops: eq, ne, contains, notContains, regex, gt, gte, lt, lte, in, notIn, isEmpty, notEmpty, before, after. Nested fields: "address.city". Empty: keep every row.

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

Whether a row must pass every filter, or at least one of them.

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

Rows with the same values in these fields count as duplicates; the first one is kept. Works across all sources in the run. Empty: no dedupe.

## `normalizeForDedupe` (type: `boolean`):

On: trim, lower case, collapse spaces, Unicode NFKC (full-width and half-width forms match), and ignore the query string and trailing slash of URLs.

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

Keep only these fields, in this order. Empty: keep all fields.

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

Old name to new name, for example {"company_name": "name"}. Applied after Fields to keep.

## `flatten` (type: `boolean`):

Turn {"a": {"b": 1}} into {"a.b": 1}.

## `onlyNewSinceLastRun` (type: `boolean`):

Needs Dedupe by fields. Keeps a saved list of the keys of rows this Actor returned to you; a row whose key is in the list is dropped and not charged. The newest 5,000,000 keys are kept.

## `exportCsv` (type: `boolean`):

Also write the kept rows to a CSV file (EXPORT.csv in the run's key-value store). The link is in the OUTPUT record.

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

Stop after this many rows are kept. 0: no limit.

## Actor input object example

```json
{
  "sources": [
    "https://raw.githubusercontent.com/datasets/airport-codes/main/data/airport-codes.csv"
  ],
  "format": "auto",
  "filters": [
    {
      "field": "iso_country",
      "op": "eq",
      "value": "JP"
    },
    {
      "field": "type",
      "op": "eq",
      "value": "large_airport"
    }
  ],
  "filterMode": "all",
  "dedupeBy": [
    "municipality"
  ],
  "normalizeForDedupe": true,
  "flatten": false,
  "onlyNewSinceLastRun": false,
  "exportCsv": false,
  "maxRows": 0
}
```

# Actor output Schema

## `rows` (type: `string`):

The rows that passed the filters and were not duplicates.

## `summary` (type: `string`):

Rows read, kept and dropped, per-source results, seconds and peak memory.

## `csv` (type: `string`):

Only when Export CSV is on.

# 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 = {
    "sources": [
        "https://raw.githubusercontent.com/datasets/airport-codes/main/data/airport-codes.csv"
    ],
    "filters": [
        {
            "field": "iso_country",
            "op": "eq",
            "value": "JP"
        },
        {
            "field": "type",
            "op": "eq",
            "value": "large_airport"
        }
    ],
    "dedupeBy": [
        "municipality"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("northbell/dataset-stream-transform").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 = {
    "sources": ["https://raw.githubusercontent.com/datasets/airport-codes/main/data/airport-codes.csv"],
    "filters": [
        {
            "field": "iso_country",
            "op": "eq",
            "value": "JP",
        },
        {
            "field": "type",
            "op": "eq",
            "value": "large_airport",
        },
    ],
    "dedupeBy": ["municipality"],
}

# Run the Actor and wait for it to finish
run = client.actor("northbell/dataset-stream-transform").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 '{
  "sources": [
    "https://raw.githubusercontent.com/datasets/airport-codes/main/data/airport-codes.csv"
  ],
  "filters": [
    {
      "field": "iso_country",
      "op": "eq",
      "value": "JP"
    },
    {
      "field": "type",
      "op": "eq",
      "value": "large_airport"
    }
  ],
  "dedupeBy": [
    "municipality"
  ]
}' |
apify call northbell/dataset-stream-transform --silent --output-dataset

```

## MCP server setup

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

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/X0d4EVfoG3ybeiX0i/builds/u8lf6U3Xdpgfj4JHc/openapi.json
