# Filter Rows: Keep CSV, JSON or Dataset Rows by Condition (`ucchiii/filter-rows`) Actor

Filter rows of a CSV, TSV, JSON or NDJSON file or an Apify dataset with simple conditions like country = US or price > 100. Matching rows go to a dataset you can download as CSV or Excel. Empty input = free demo.

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

## Pricing

from $0.01 / 1,000 read 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

**Keep only the CSV, JSON or dataset rows that match your conditions**

**Filter rows of a CSV, TSV, JSON or NDJSON file or an Apify dataset with plain conditions like `country = US` or `price > 100`.** Paste a file link (or pick a dataset), write one condition per line, press Start: the matching rows land in a dataset you can download as CSV, Excel or JSON.

**Try it free:** leave the file empty and press **Start** — the conditions already in the form run on a built-in 20-row sample (not charged, rows carry `_demo: true`).

| condition | keeps rows where |
|---|---|
| `country = US` | the country is US (text is compared without case) |
| `price > 100` | the price is more than 100 (numbers are compared as numbers) |
| `signup_date >= 2025-06-01` | the date is on or after 1 June 2025 (ISO dates) |
| `email contains @gmail.com` | the email contains that text |
| `phone is empty` | the phone column is blank |
| `status in open, pending` | the status is one of the listed values |

- **Price:** $0.01 per 1,000 rows read, charged per row ($0.00001 a row) — 100,000 rows cost $1, whether 5 or 50,000 of them match. Failed runs and the demo are free. Store discounts apply automatically: BRONZE −10%, SILVER −20%, GOLD −30%.
- **Big files are fine:** CSV, TSV and NDJSON are read one row at a time, so a 3-million-row CSV uses about as little memory as a small one.

### How to use

1. **File URL** (a public link to a CSV, TSV, JSON or NDJSON file) **or an Apify dataset** (for example the results of a scraper run).
2. **Conditions**, one per line: `column operator value`.
3. **Keep rows that match**: *all* conditions (AND, default) or *any* condition (OR).

```json
{
  "fileUrl": "https://example.com/leads.csv",
  "conditions": ["country = US", "employees >= 50", "email is not empty"],
  "match": "all"
}
```

### Operators

`=` `!=` `>` `>=` `<` `<=` · `contains` · `not contains` · `starts with` · `ends with` · `in` (comma list) · `not in` · `is empty` · `is not empty`

- Text comparisons ignore case and surrounding spaces. `1,000` and `1000.0` both count as the number 1000.
- `>` and `<` compare numbers as numbers; other text (such as ISO dates `2025-06-01`) is compared alphabetically, which is correct for ISO dates. Blank values never pass `>` or `<`.
- Nested fields of JSON or dataset rows: `address.city = Berlin`.
- A column name with spaces works as is (`Monthly Spend >= 49`); put it in quotes if it contains an operator (`"a=b" = 1`).
- Column names are matched without case. In a CSV, a column that does not exist stops the run **before anything is charged** and lists the real column names.

### Output

- **Dataset**: every matching row with all its original columns and values, in the original order. CSV values stay exactly as in the file (a ZIP code `00123` stays `00123`). Download it as CSV, Excel, JSON, XML or HTML from the run page.
- **STATS** record: rows read, rows matched, the conditions used, the rows charged and whether the run stopped early.

### Limits (cannot be raised by input)

- Files up to 500 MB; JSON arrays up to 150 MB (an array has to be read as a whole — use NDJSON for bigger files); 5,000,000 rows read per run; 20 conditions per run
- Set a maximum charge per run to cap spend: the Actor stops cleanly when it is reached and keeps the rows found so far. `maxOutputRows` stops after that many matching rows
- Public files only (no login). Links to internal network addresses are blocked

### Pricing

Pay per event: **$0.00001 per row read** ($0.01 per 1,000 rows), charged per row. Failed runs and the demo are free.
On the Apify Free plan, the $5 of monthly platform credit covers about **500,000 rows** a month — enough to try it on real data.

### FAQ

**Does it change my data?** No. Rows are copied as they are; only the rows that do not match are left out.
**Excel files?** Convert them first (for example with the Excel to JSON Actor from the same developer), or save the sheet as CSV.

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

### More tools from the same developer

- [CSV / XLSX Converter](https://apify.com/ucchiii/csv-xlsx-converter) — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other
- [Remove Duplicates](https://apify.com/ucchiii/dataset-dedup-merge) — merge Apify datasets and remove duplicates by the fields you choose
- [Dataset Splitter](https://apify.com/ucchiii/dataset-splitter) — split a dataset or CSV/JSON file into parts by rows, parts, column value or size, or take a random sample
- [Google Sheets Export](https://apify.com/ucchiii/google-sheets-export) — export an Apify dataset to Google Sheets

# Actor input Schema

## `fileUrl` (type: `string`):

Public http(s) link to the file to filter (up to 500 MB; JSON arrays up to 150 MB, NDJSON has no extra limit). Use this OR an Apify dataset. Leave both empty for a free demo on a built-in sample.

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

Dataset to filter, for example the defaultDatasetId of a scraper run. You can paste a dataset URL from Apify Console too.

## `conditions` (type: `array`):

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 (2025-06-01) work with > and <. Nested fields: address.city. Put a column name with an operator inside it in quotes.

## `match` (type: `string`):

Default: all conditions must match.

## `maxOutputRows` (type: `integer`):

Optional. Empty = keep every matching row. Rows read until then are charged.

## `inputFormat` (type: `string`):

Default auto: from the file extension, content type and content. Ignored for datasets.

## `delimiter` (type: `string`):

Default auto: guessed from the header line.

## `encoding` (type: `string`):

Default auto: UTF-8, then Shift_JIS if kana are found, then Windows-1252.

## Actor input object example

```json
{
  "conditions": [
    "country = US",
    "monthly_usd >= 49"
  ],
  "match": "all",
  "inputFormat": "auto",
  "delimiter": "auto",
  "encoding": "auto"
}
```

# Actor output Schema

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

Every row that matched, with all its original columns and values. Download as CSV, JSON or Excel.

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

Record STATS: rows read, rows matched, the conditions used, 1,000-row units charged and whether the run stopped early.

# 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 = {
    "conditions": [
        "country = US",
        "monthly_usd >= 49"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/filter-rows").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 = { "conditions": [
        "country = US",
        "monthly_usd >= 49",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/filter-rows").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 '{
  "conditions": [
    "country = US",
    "monthly_usd >= 49"
  ]
}' |
apify call ucchiii/filter-rows --silent --output-dataset

```

## MCP server setup

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

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/xL1p1IC4f0g77cJ3n/builds/CXSjfYlLDvzLx1fVZ/openapi.json
