# Join Datasets: Left Join, VLOOKUP by Key Column (`ucchiii/dataset-join-lookup`) Actor

Joins two tables on a key column: Apify datasets or CSV/JSON files by URL. Inner, left, right or full outer join, several keys, case and space tolerant matching, or VLOOKUP-style pulling of chosen columns. Empty input runs a free demo.

- **URL**: https://apify.com/ucchiii/dataset-join-lookup.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 $0.25 / 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

**Join two tables on a key column: left, inner, right or full outer join, or a VLOOKUP that pulls only the columns you pick.**

You have two lists that share an ID: orders and customers, scraped products and your price list, leads and a blocklist. You want the customer's plan next to each order, or the rows that have no partner. In a spreadsheet that is a VLOOKUP; in a pipeline it is a join. This Actor does it for **Apify datasets and CSV / TSV / JSON / NDJSON files** from the Console form, with no code and no spreadsheet row limit.

- **Cost:** $0.35 per 1,000 output rows ($0.00035 per row). **The $5 monthly free credit covers about 14,000 rows.** The demo, failed runs and rows over your limit are free.
- **Try it free:** clear the four table fields and press **Start**. A small orders sample is joined to a customers sample (not charged, rows carry `_demo: true`).

### What you get

Left table: orders. Right table: customers. Joined on `email` with *Ignore case* and *Trim spaces* on, `rightColumns: ["name", "city", "plan"]`, prefix `customer_`:

| order_id | email | item | amount | city | name | customer_city | plan |
|---|---|---|---|---|---|---|---|
| A-1001 | aiko@example.com | Keyboard | 89 | Osaka | Aiko Tanaka | Kobe | pro |
| A-1002 | `Ben@Example.com` | Mouse | 25.5 | Leeds | Ben Carter | Leeds | free |
| A-1005 | zoe@example.com | Cable | 7.9 | Oslo | null | null | null |

- The left columns come first, unchanged. The right columns follow. `city` exists on both sides, so the right one is added as `customer_city`.
- `Ben@Example.com` found `ben@example.com` because spaces and case were ignored. The output keeps the original value.
- `zoe@example.com` has no customer: with a left join the order stays, the right columns are `null`.

### Which tool is this?

| You want to... | Use |
|---|---|
| Add the columns of another table to your rows, matched by a key (**this Actor**) | **Join Datasets** |
| Stack several tables on top of each other with the same columns | Merge Datasets |
| Remove duplicate rows by the fields you choose | Remove Duplicates (Dataset Merge & Dedup) |

Merge Datasets and Remove Duplicates work **vertically**: more rows, same columns. Join Datasets works **horizontally**: the same rows (or the matching ones) with more columns.

### What it does

- **Four join types.** Left (the default, what VLOOKUP does: no left row is lost), inner (only rows found in both), right, and full outer. Right and full outer also output the right rows no left row matched.
- **VLOOKUP mode.** Name the right columns to bring, in the order you want. Leave it empty to bring every right column except the key. Together with *first match* the output has exactly one row per left row.
- **Several keys.** Up to five key columns, matched by position: `["country", "year"]` with `["Country Code", "Year"]`. Key columns may have different names on each side; nested fields work with dots (`address.zip`).
- **Forgiving matching.** *Trim spaces* (on by default, also full-width spaces and line breaks) and *Ignore upper/lower case* (off by default). Numbers match their text form: `123`, `123.0` and `"123"` are the same key, so a CSV file can be joined to a dataset. Leading zeros are kept: `00123` is not `123`. An empty key (null, empty text, spaces only) matches nothing.
- **The same key several times on the right.** *All* (default) gives one output row per matching right row, like a database join. *First* or *last* keeps one right row per key.
- **Column name clashes.** A right column whose name already exists on the left gets your prefix (`city` becomes `right_city`); a second clash adds `_2`. You can also prefix every right column.
- **Match column.** Turn on `_match` to get `both`, `left_only` or `right_only` on every row, and filter the rows without a partner.
- **Big tables.** The right table is held in memory as a lookup (up to 1,000,000 rows); the left table is streamed. Make the larger table the left one, and list only the right columns you need, so the default 1 GB of memory is enough for millions of left rows.

### How to use

1. **Left table**: pick a dataset, or paste a file URL. This is the table whose rows you keep.
2. **Right table**: the lookup table, a dataset or a file URL.
3. **Left key columns** (and **Right key columns** if the names differ).
4. Choose the **join type**, the **right columns to bring**, and the matching options.

```json
{
  "leftDatasetId": "WkzbQMuFYuamGv3YF",
  "rightFileUrl": "https://example.com/customers.csv",
  "leftKeys": ["email"],
  "rightKeys": ["Email Address"],
  "joinType": "left",
  "rightColumns": ["name", "plan"],
  "multipleMatches": "first",
  "ignoreCase": true
}
```

### Output

- **Dataset**: the joined rows, ready to download as CSV, Excel, JSON, XML or HTML. Values are copied unchanged: numbers, booleans and nested objects from datasets stay as they are, and CSV values stay text exactly as in the file.
- **STATS** record (key-value store): row counts of both tables, how many left rows found a partner and how many did not, right rows nobody matched, the keys, the output columns and how right columns were renamed, rows charged, and notes (for example rows with an empty key).

| field | meaning |
|---|---|
| *left columns* | every column of the left table, unchanged |
| *right columns* | the columns brought from the right table (renamed with the prefix when they clash) |
| `_match` | `both` / `left_only` / `right_only` (only with **Add a match column**) |
| `_demo` | `true` on the free demo rows |

### Limits (cannot be raised by input)

- One left and one right table per run. Right table up to 1,000,000 rows; up to 1,000,000 output rows per run (the default **Max output rows** is 100,000); up to 5 key columns and 2,000 columns
- Files up to 100 MB each; JSON arrays up to 50 MB (use NDJSON for bigger files). Excel files are not read: save them as CSV first. Public links only (no login); addresses on internal networks are blocked
- A table that cannot be read (wrong dataset ID, HTTP error, broken JSON), or a key column that no row has, stops the run **before anything is written or charged**
- Set a maximum cost per run to cap spend: the run stops cleanly at that number of rows (status Succeeded), keeps what was joined and says so in the status message and STATS

### Pricing

Pay per event: **$0.00035 per output row** ($0.35 per 1,000 rows). Input rows are free; you pay for the rows that are written. A key that repeats on both sides multiplies rows, so use *first match* for a lookup and keep **Max output rows** at a value you are happy to pay for. Failed runs, rows over the limit and the demo are not charged.
Store discounts apply automatically: BRONZE −10%, SILVER −20%, GOLD −30%.
On the Apify Free plan, the $5 of monthly platform credit covers about 14,000 rows a month.

### FAQ

**Is it the same as VLOOKUP?** Yes for a left join with *first match*: every left row stays, and the columns you name are looked up in the right table. Unlike VLOOKUP the key does not have to be the first column, and you can match on several columns.

**Why did my left rows multiply?** The right table has the same key more than once and *When the right table has the same key several times* is on `all`. Choose `first` or `last` for a one-to-one lookup.

**Why is nothing matched?** Compare the key values in both tables: stray spaces, upper/lower case and leading zeros are the usual reasons. Turn on *Trim spaces* and *Ignore case*. With `outer` and the match column on you can see the unmatched rows from both sides.

**Does it remove duplicates or stack tables?** No. Use Remove Duplicates to drop duplicate rows, and Merge Datasets to put tables on top of each other.

**Does it work with datasets from other Actors' runs?** Yes, any dataset your account can read. Paste the `defaultDatasetId` of a run or the dataset URL from Apify Console.

### More tools from the same developer

- [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
- [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
- [Dataset Transform](https://apify.com/ucchiii/dataset-transform) — flatten, filter, rename and convert any Apify dataset, export CSV / JSON / JSONL with a link
- [CSV to Excel Converter](https://apify.com/ucchiii/csv-xlsx-converter) — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other

# Actor input Schema

## `leftDatasetId` (type: `string`):

Dataset ID (a finished run's 'defaultDatasetId') or a dataset URL from Apify Console for the left table: the table whose rows you keep and extend. Give either this or 'Left table: file URL'. Leave all four table fields empty for a free demo.

## `leftFileUrl` (type: `string`):

Public http(s) link to a CSV, TSV, JSON or NDJSON file for the left table, up to 100 MB (JSON arrays up to 50 MB). Links to internal networks are blocked. Give either this or a left dataset.

## `rightDatasetId` (type: `string`):

Dataset ID or dataset URL for the right table: the lookup table whose columns are added to the left rows. It is held in memory, so use the smaller table here. Give either this or 'Right table: file URL'.

## `rightFileUrl` (type: `string`):

Public http(s) link to a CSV, TSV, JSON or NDJSON file for the right table (up to 1,000,000 rows, 100 MB). Give either this or a right dataset.

## `leftKeys` (type: `array`):

Column(s) of the left table that identify a row, such as 'email' or 'sku'. With several columns all of them must match (up to 5, matched to the right key columns by position). Nested fields work with dots (address.zip). Required.

## `rightKeys` (type: `array`):

Column(s) of the right table that hold the key, in the same order as the left key columns. Leave empty if the columns have the same names in both tables. The right key columns are not repeated in the output.

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

Which rows to keep. Left (default) is what VLOOKUP does: no left row is lost. Inner keeps only rows with a partner. Right and full outer also output the right rows that no left row matched. Default: left.

## `rightColumns` (type: `array`):

VLOOKUP mode: names of the right-table columns to add to the left rows, in this order. Empty = every right column except the key columns. Listing only what you need also saves memory for a large right table.

## `multipleMatches` (type: `string`):

A left row whose key appears in several right rows gives one output row per right row ('all'), which can multiply rows and cost. 'first' or 'last' keeps one right row per key so the left row count stays the same. Default: all.

## `trimKeys` (type: `boolean`):

Ignore spaces, tabs and line breaks (also full-width spaces) at the start and end of key values when matching. The output keeps the original values. Default: on.

## `ignoreCase` (type: `boolean`):

Match 'ANN@Example.com' with 'ann@example.com'. Numbers always match their text form (123, 123.0 and '123' are the same key); leading zeros are kept ('00123' is not 123). Default: off.

## `rightPrefix` (type: `string`):

When a column brought from the right table has the same name as a left column, it is added as prefix + name (city becomes right_city). If that name is taken too, \_2, *3 ... is added. Default: right*.

## `prefixAllRightColumns` (type: `boolean`):

Add the prefix to all columns brought from the right table, not only the ones whose names repeat. Default: off.

## `addMatchColumn` (type: `boolean`):

Add a '\_match' column: 'both' when the row found a partner, 'left_only' or 'right_only' when it did not. Handy to list the rows without a partner. Default: off.

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

Stop after this many output rows. A key that repeats in both tables multiplies rows, so this caps run time and cost ($0.35 per 1,000 rows). Rows beyond the limit are not charged. Maximum 1,000,000. Default: 100,000.

## Actor input object example

```json
{
  "leftFileUrl": "https://raw.githubusercontent.com/datasets/country-list/master/data.csv",
  "rightFileUrl": "https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv",
  "leftKeys": [
    "Code"
  ],
  "rightKeys": [
    "ISO3166-1-Alpha-2"
  ],
  "joinType": "left",
  "rightColumns": [
    "Capital",
    "ISO4217-currency_alphabetic_code",
    "Dial"
  ],
  "multipleMatches": "all",
  "trimKeys": true,
  "ignoreCase": false,
  "rightPrefix": "right_",
  "prefixAllRightColumns": false,
  "addMatchColumn": false,
  "maxOutputRows": 100000
}
```

# Actor output Schema

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

The output rows: left columns plus the columns brought from the right table. Download as CSV, JSON, Excel and more.

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

Record STATS: row counts per table, how many left rows found a partner, right rows nobody matched, the output columns and how right columns were renamed, rows charged and notes.

# 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 = {
    "leftFileUrl": "https://raw.githubusercontent.com/datasets/country-list/master/data.csv",
    "rightFileUrl": "https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv",
    "leftKeys": [
        "Code"
    ],
    "rightKeys": [
        "ISO3166-1-Alpha-2"
    ],
    "rightColumns": [
        "Capital",
        "ISO4217-currency_alphabetic_code",
        "Dial"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/dataset-join-lookup").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 = {
    "leftFileUrl": "https://raw.githubusercontent.com/datasets/country-list/master/data.csv",
    "rightFileUrl": "https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv",
    "leftKeys": ["Code"],
    "rightKeys": ["ISO3166-1-Alpha-2"],
    "rightColumns": [
        "Capital",
        "ISO4217-currency_alphabetic_code",
        "Dial",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/dataset-join-lookup").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 '{
  "leftFileUrl": "https://raw.githubusercontent.com/datasets/country-list/master/data.csv",
  "rightFileUrl": "https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv",
  "leftKeys": [
    "Code"
  ],
  "rightKeys": [
    "ISO3166-1-Alpha-2"
  ],
  "rightColumns": [
    "Capital",
    "ISO4217-currency_alphabetic_code",
    "Dial"
  ]
}' |
apify call ucchiii/dataset-join-lookup --silent --output-dataset

```

## MCP server setup

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

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/3jmeUNgECtCU1lLNo/builds/VzeWq0PNvi55hkYYe/openapi.json
