# Dataset Filter & Transform (`nerolabs/dataset-filter-transform`) Actor

Filter rows by rule (AND/OR conditions, 14 operators) and transform them (rename, drop/keep fields, trim/case, computed fields, type casting, regex extraction) for any Apify dataset or JSON array, then download as CSV/Excel. No scraping, works on data you already have.

- **URL**: https://apify.com/nerolabs/dataset-filter-transform.md
- **Developed by:** [Adam Pearce](https://apify.com/nerolabs) (community)
- **Categories:** Developer tools, Automation, Agents
- **Stats:** 1 total users, 1 monthly users, 93.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 row kepts

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

**Stop writing one-off scripts to clean up scraper output.** Dataset Filter & Transform takes any Apify dataset (or a plain JSON array you paste in) and lets you **filter rows by rule** and **transform fields** — rename, drop, trim, uppercase/lowercase, cast types, build a computed field from arithmetic, extract text with a regex, or template a new field from existing ones — all from a JSON config, no code, no spreadsheet formulas to babysit. Point it at the output of any scraper on the [Apify Store](https://apify.com/store) and get back exactly the rows and fields you actually wanted, plus a ready-to-open CSV or Excel file.

### Why use Dataset Filter & Transform?

Every scraper dumps more than you need: rows you don't want, messy strings, numbers stored as `"$1,234.50"` text, fields with the wrong name for your CRM import. The usual fix is a throwaway Python script or a pile of Excel formulas, redone every time. This Actor turns that into a reusable, scheduled, API-callable step:

- **Sales & lead gen**: keep only leads in your target country with a phone number, trim and lowercase emails, compute a lead score.
- **E-commerce**: keep only in-stock products under a price threshold, cast price strings to real numbers, compute a margin field.
- **Data pipelines**: chain this after any scraper (via Apify's dataset-to-dataset integrations or a schedule) to always hand the next step clean, filtered data.
- **CRM prep**: rename scraped field names to match your import template before exporting to CSV.

Because it runs on Apify, you get scheduling, API access, dataset integrations (Zapier, Make, Google Sheets, webhooks), and full run history for free.

### How to use Dataset Filter & Transform

1. Click **Try for free** (or **Start**) on this Actor.
2. Either pick an existing dataset in **Dataset to process**, or paste rows into **Data (inline)**.
3. Add **Transform steps** — a JSON list of operations applied in order (see below).
4. Add **Filter conditions** — rows are kept only if they pass, using AND or OR.
5. Pick export formats (CSV / Excel) if you want a downloadable file, and run.

The default input runs in a couple of seconds against a small built-in example so you can see exactly how it behaves before pointing it at your own data.

### Transform steps

Each step is one JSON object; steps run top to bottom, so a later step can use an earlier step's output (e.g. trim a field, then reference it in a template).

| `op` | What it does | Example |
|---|---|---|
| `rename` | Rename a field | `{"op":"rename","from":"e-mail","to":"email"}` |
| `drop` | Remove fields | `{"op":"drop","fields":["internal_id"]}` |
| `keep` | Keep only listed fields, drop the rest | `{"op":"keep","fields":["name","email"]}` |
| `trim` / `uppercase` / `lowercase` | String case/whitespace ops | `{"op":"trim","field":"name"}` |
| `cast` | Convert to `number`, `string`, or `boolean` | `{"op":"cast","field":"price","to":"number"}` |
| `addField` | Build a new field from a template | `{"op":"addField","field":"fullName","template":"{{first}} {{last}}"}` |
| `compute` | Arithmetic over numeric fields | `{"op":"compute","field":"total","expression":"price * qty","round":2}` |
| `regexExtract` | Pull text out with a regex | `{"op":"regexExtract","field":"sku","pattern":"ITEM-(\\d+)-","into":"itemNumber"}` |

Number-parsing is lenient by default: `"$1,234.50"`, `"49 USD"` and `"(300)"` (accounting negative) all read as real numbers for `cast` and `compute`.

### Filter conditions

Each condition is `{"field": "...", "operator": "...", "value": ...}`. Combine every condition with **AND** (must match all) or **OR** (match any).

Operators: `equals`, `notEquals`, `contains`, `notContains`, `startsWith`, `endsWith`, `greaterThan`, `lessThan`, `greaterOrEqual`, `lessOrEqual`, `isEmpty`, `isNotEmpty`, `matchesRegex`, `in`, `notIn`.

String comparisons are case-insensitive by default (`"US"` matches `"us"`); turn on **Case-sensitive filters by default**, or set `"caseSensitive": true` on one condition, to require an exact match.

### Input

See the **Input** tab for the full schema. The two ways to bring in data:

- **`datasetId`** — point at any existing Apify dataset (yours or from another Actor's run).
- **`data`** — paste a JSON array directly for quick, ad-hoc jobs.

```json
{
  "data": [
    { "name": "  jane doe ", "country": "US", "revenue": "$12,500.00", "active": "yes" }
  ],
  "transforms": [
    { "op": "trim", "field": "name" },
    { "op": "cast", "field": "revenue", "to": "number" }
  ],
  "filters": [
    { "field": "country", "operator": "equals", "value": "US" },
    { "field": "revenue", "operator": "greaterOrEqual", "value": 1000 }
  ],
  "filterCombineMode": "AND",
  "exportFormats": ["csv", "xlsx"]
}
```

### Output

Every kept, transformed row is pushed to the dataset:

```json
{
  "name": "jane doe",
  "country": "US",
  "revenue": 12500,
  "active": "yes"
}
```

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel directly from the Apify Console, or request a ready-made CSV/Excel file via `exportFormats`. A run summary (rows in, kept, excluded, and any field a transform step couldn't honestly apply) is saved to the key-value store as `FILTER_TRANSFORM_SUMMARY`.

### Pricing

Pay-per-event, no subscription:

- **$0.002** per row kept (a row that passed your filter and was written out)
- **$0.01** per file export (CSV or Excel)
- A small per-GB run-start fee (the platform default)

A typical cleanup of a few thousand scraped rows down to the few hundred you actually wanted costs a few dollars. Rows that get filtered out are never charged.

### Tips

- Filters run **after** transforms, so you can compute a field and then filter on it in the same run (see the default example: `cast` a price string to a number, then filter on the numeric value).
- Use `keep` as a last transform step to guarantee a clean, fixed column set for your CSV/Excel export, regardless of what extra fields the source data carries.
- `maxItems` caps how many input rows are loaded, useful as a cost guard on very large datasets before you're sure the filter is right.

### FAQ

**Does this work on any dataset?** Yes — this Actor processes only the data you already have (your own dataset or pasted JSON). It doesn't scrape anything, so there's no target-site data-terms question to worry about.

**What happens if a filter field doesn't exist in my data?** You'll get a clear warning telling you no row had that field, so a typo doesn't just silently exclude everything with no explanation.

**What happens if `compute` or `cast` can't parse a value?** The field is set to `null` and counted in the run summary, never guessed.

Found a bug or want a feature? Open an issue on the **Issues** tab, checked daily.

# Actor input Schema

## `datasetId` (type: `string`):

Pick an existing Apify dataset (for example the output of any scraper run). Use this OR 'Data (inline)' below, not both. Declaring it this way is what lets this Actor run with limited permissions: it may read the dataset you point at, and nothing else on your account.

## `data` (type: `array`):

A JSON array of records to filter and transform, for ad-hoc data instead of a dataset ID.

## `transforms` (type: `array`):

A list of steps applied to every row, top to bottom, before any filtering happens. Each step reads/writes top-level fields (dotted paths like 'address.city' can still be READ inside a template or expression, just not written directly). Steps: {"op":"rename","from":"a","to":"b"}, {"op":"drop","fields":\["a"]}, {"op":"keep","fields":\["a","b"]} (keep only these, drop everything else), {"op":"trim"|"uppercase"|"lowercase","field":"a"}, {"op":"cast","field":"a","to":"number"|"string"|"boolean"}, {"op":"addField","field":"c","template":"{{a}} {{b}}"} (string template, {{dotted.path}} placeholders), {"op":"compute","field":"c","expression":"price \* qty","round":2} (arithmetic +-\*/ over numeric fields, dotted paths allowed as variable names), {"op":"regexExtract","field":"a","pattern":"...","flags":"i","group":1,"into":"b"} (defaults to overwriting 'field' if 'into' is omitted).

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

Rows are kept only if they pass these conditions (combined per 'Combine filters with' below). Each item: {"field": "revenue", "operator": "greaterOrEqual", "value": 1000}. Operators: equals, notEquals, contains, notContains, startsWith, endsWith, greaterThan, lessThan, greaterOrEqual, lessOrEqual, isEmpty, isNotEmpty, matchesRegex (value = pattern), in, notIn (value = array). Leave empty to keep every row (transform-only mode). 'caseSensitive' can be set per-condition to override the global default below.

## `filterCombineMode` (type: `string`):

AND: a row must pass every condition. OR: a row passes if it matches any one condition.

## `caseSensitiveFilters` (type: `boolean`):

Off (default) treats 'US', 'us' and ' US ' as the same value for equals/contains/startsWith/endsWith/in, which is what scraped or hand-entered data usually needs. Turn on to require an exact, byte-for-byte match. Override per-condition with a 'caseSensitive' key on that condition.

## `lenientNumbers` (type: `boolean`):

Read numbers stored as text, like '$1,234.50', '49 USD' or '(300)', as numbers for numeric filters, 'cast to number', and 'compute'. Scraped prices almost always need this. Turn off to only accept real numbers and plain numeric strings.

## `exportFormats` (type: `array`):

Also save the kept, transformed rows as a real downloadable file in the run's key-value store. CSV opens anywhere; XLSX opens in Excel and Google Sheets with a bold, frozen header row.

## `maxItems` (type: `integer`):

Stop loading after this many rows from the dataset (a cost guard for large datasets). There is a hard safety ceiling of 200,000 rows per run regardless.

## Actor input object example

```json
{
  "data": [
    {
      "name": "  jane doe ",
      "email": "JANE@Example.com",
      "country": "US",
      "revenue": "$12,500.00",
      "active": "yes",
      "signupDate": "2026-03-14"
    },
    {
      "name": "Bob Smith",
      "email": "bob@example.com",
      "country": "GB",
      "revenue": 400,
      "active": "no",
      "signupDate": "2026-05-02"
    },
    {
      "name": "Ana Silva",
      "email": "ana@example.com",
      "country": "BR",
      "revenue": "2,300",
      "active": "yes",
      "signupDate": "2026-06-19"
    },
    {
      "name": "  Chen Wei",
      "email": "chen@example.com",
      "country": "US",
      "revenue": "n/a",
      "active": "yes",
      "signupDate": "2026-07-01"
    },
    {
      "name": "Sam Lee",
      "email": "sam@example.com",
      "country": "US",
      "revenue": 9800,
      "active": "yes",
      "signupDate": "2026-08-05"
    }
  ],
  "transforms": [
    {
      "op": "trim",
      "field": "name"
    },
    {
      "op": "lowercase",
      "field": "email"
    },
    {
      "op": "cast",
      "field": "revenue",
      "to": "number"
    },
    {
      "op": "addField",
      "field": "summary",
      "template": "{{name}} ({{country}}) - {{email}}"
    }
  ],
  "filters": [
    {
      "field": "country",
      "operator": "equals",
      "value": "US"
    },
    {
      "field": "active",
      "operator": "equals",
      "value": "yes"
    },
    {
      "field": "revenue",
      "operator": "greaterOrEqual",
      "value": 1000
    }
  ],
  "filterCombineMode": "AND",
  "caseSensitiveFilters": false,
  "lenientNumbers": true,
  "exportFormats": [
    "csv",
    "xlsx"
  ]
}
```

# Actor output Schema

## `filteredRows` (type: `string`):

Every row that passed the filter, after the transform steps were applied.

## `csvFile` (type: `string`):

A ready-to-open CSV file of the kept, transformed rows, if requested.

## `xlsxFile` (type: `string`):

A ready-to-open Excel (.xlsx) file of the kept, transformed rows, if requested.

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

Row counts in, kept and excluded, any transform steps that couldn't be applied to some rows, and warnings from this run.

# 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 = {
    "data": [
        {
            "name": "  jane doe ",
            "email": "JANE@Example.com",
            "country": "US",
            "revenue": "$12,500.00",
            "active": "yes",
            "signupDate": "2026-03-14"
        },
        {
            "name": "Bob Smith",
            "email": "bob@example.com",
            "country": "GB",
            "revenue": 400,
            "active": "no",
            "signupDate": "2026-05-02"
        },
        {
            "name": "Ana Silva",
            "email": "ana@example.com",
            "country": "BR",
            "revenue": "2,300",
            "active": "yes",
            "signupDate": "2026-06-19"
        },
        {
            "name": "  Chen Wei",
            "email": "chen@example.com",
            "country": "US",
            "revenue": "n/a",
            "active": "yes",
            "signupDate": "2026-07-01"
        },
        {
            "name": "Sam Lee",
            "email": "sam@example.com",
            "country": "US",
            "revenue": 9800,
            "active": "yes",
            "signupDate": "2026-08-05"
        }
    ],
    "transforms": [
        {
            "op": "trim",
            "field": "name"
        },
        {
            "op": "lowercase",
            "field": "email"
        },
        {
            "op": "cast",
            "field": "revenue",
            "to": "number"
        },
        {
            "op": "addField",
            "field": "summary",
            "template": "{{name}} ({{country}}) - {{email}}"
        }
    ],
    "filters": [
        {
            "field": "country",
            "operator": "equals",
            "value": "US"
        },
        {
            "field": "active",
            "operator": "equals",
            "value": "yes"
        },
        {
            "field": "revenue",
            "operator": "greaterOrEqual",
            "value": 1000
        }
    ],
    "exportFormats": [
        "csv",
        "xlsx"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nerolabs/dataset-filter-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 = {
    "data": [
        {
            "name": "  jane doe ",
            "email": "JANE@Example.com",
            "country": "US",
            "revenue": "$12,500.00",
            "active": "yes",
            "signupDate": "2026-03-14",
        },
        {
            "name": "Bob Smith",
            "email": "bob@example.com",
            "country": "GB",
            "revenue": 400,
            "active": "no",
            "signupDate": "2026-05-02",
        },
        {
            "name": "Ana Silva",
            "email": "ana@example.com",
            "country": "BR",
            "revenue": "2,300",
            "active": "yes",
            "signupDate": "2026-06-19",
        },
        {
            "name": "  Chen Wei",
            "email": "chen@example.com",
            "country": "US",
            "revenue": "n/a",
            "active": "yes",
            "signupDate": "2026-07-01",
        },
        {
            "name": "Sam Lee",
            "email": "sam@example.com",
            "country": "US",
            "revenue": 9800,
            "active": "yes",
            "signupDate": "2026-08-05",
        },
    ],
    "transforms": [
        {
            "op": "trim",
            "field": "name",
        },
        {
            "op": "lowercase",
            "field": "email",
        },
        {
            "op": "cast",
            "field": "revenue",
            "to": "number",
        },
        {
            "op": "addField",
            "field": "summary",
            "template": "{{name}} ({{country}}) - {{email}}",
        },
    ],
    "filters": [
        {
            "field": "country",
            "operator": "equals",
            "value": "US",
        },
        {
            "field": "active",
            "operator": "equals",
            "value": "yes",
        },
        {
            "field": "revenue",
            "operator": "greaterOrEqual",
            "value": 1000,
        },
    ],
    "exportFormats": [
        "csv",
        "xlsx",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("nerolabs/dataset-filter-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 '{
  "data": [
    {
      "name": "  jane doe ",
      "email": "JANE@Example.com",
      "country": "US",
      "revenue": "$12,500.00",
      "active": "yes",
      "signupDate": "2026-03-14"
    },
    {
      "name": "Bob Smith",
      "email": "bob@example.com",
      "country": "GB",
      "revenue": 400,
      "active": "no",
      "signupDate": "2026-05-02"
    },
    {
      "name": "Ana Silva",
      "email": "ana@example.com",
      "country": "BR",
      "revenue": "2,300",
      "active": "yes",
      "signupDate": "2026-06-19"
    },
    {
      "name": "  Chen Wei",
      "email": "chen@example.com",
      "country": "US",
      "revenue": "n/a",
      "active": "yes",
      "signupDate": "2026-07-01"
    },
    {
      "name": "Sam Lee",
      "email": "sam@example.com",
      "country": "US",
      "revenue": 9800,
      "active": "yes",
      "signupDate": "2026-08-05"
    }
  ],
  "transforms": [
    {
      "op": "trim",
      "field": "name"
    },
    {
      "op": "lowercase",
      "field": "email"
    },
    {
      "op": "cast",
      "field": "revenue",
      "to": "number"
    },
    {
      "op": "addField",
      "field": "summary",
      "template": "{{name}} ({{country}}) - {{email}}"
    }
  ],
  "filters": [
    {
      "field": "country",
      "operator": "equals",
      "value": "US"
    },
    {
      "field": "active",
      "operator": "equals",
      "value": "yes"
    },
    {
      "field": "revenue",
      "operator": "greaterOrEqual",
      "value": 1000
    }
  ],
  "exportFormats": [
    "csv",
    "xlsx"
  ]
}' |
apify call nerolabs/dataset-filter-transform --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nerolabs/dataset-filter-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/4hGfRCihgwdC4fEI2/builds/9c2tm8LtnAHPkyGIZ/openapi.json
