# CSV anti join

`csv-anti-join` · version 1.0.0 · CSV & tables · free, no key needed

Keep left CSV rows whose exact key tuples do not appear in the right document.

**Use when you need to: csv anti join · keep unmatched left csv rows · csv rows absent from right keys.**

## Supported

- csv anti join
- keep unmatched left csv rows
- csv rows absent from right keys

## Not supported

- inner join
- left join
- outer join
- fuzzy keys
- numeric keys
- suffix collision renaming
- read files
- fetch urls

## Behavior

- keys names unique existing headers on both sides; equality uses exact string tuples with no trimming, case folding, or type coercion.
- Output CSV uses left headers and left cells only, in original left data-row order.
- Duplicate left keys are kept when unmatched; duplicate right keys only populate the set of right key tuples.
- Empty documents without headers are rejected. Header-only right keeps every left data row. Header-only left yields header-only output.
- rows_in is the number of left data rows; rows_out is the number of unmatched left data rows kept.
- The first left header name may not begin with U+FEFF because it is ambiguous with a CSV byte-order mark.

## Input

- `left` (string, required): max length 256000
- `right` (string, required): max length 256000
- `keys` (array of string, required): min items 1; max items 32; each min length 1

## Output

- `csv` (string, required): max length 256000
- `rows_in` (integer, required)
- `rows_out` (integer, required)

## Limits

- max input bytes: 256000
- max data rows: 5000
- max columns: 256
- max header name bytes: 256
- max keys: 32
- max output bytes: 256000

## Example

Request input:

```json
{
  "left": "id,name\n1,Ada\n2,Lin\n3,Grace\n",
  "right": "id,city\n2,London\n4,Paris\n",
  "keys": [
    "id"
  ]
}
```

Response:

```json
{
  "result": {
    "csv": "id,name\n1,Ada\n3,Grace\n",
    "rows_in": 3,
    "rows_out": 2
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "csv-anti-join",
  "version": "1.0.0",
  "input": {
    "left": "id,name\n1,Ada\n2,Lin\n3,Grace\n",
    "right": "id,city\n2,London\n4,Paris\n",
    "keys": [
      "id"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-anti-join/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"left":"id,name\n1,Ada\n2,Lin\n3,Grace\n","right":"id,city\n2,London\n4,Paris\n","keys":["id"]}'
```

The machine-readable contract is at [/v1/tools/csv-anti-join/versions/1.0.0](/v1/tools/csv-anti-join/versions/1.0.0).

### CLI

```sh
node cli.mjs run csv-anti-join 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [CSV left join](/tools/csv-left-join): Left join two CSV documents on exact named key columns.
- [CSV inner join](/tools/csv-inner-join): Inner join two CSV documents on exact named key columns.
- [CSV row diff](/tools/csv-row-diff): Compare two CSV documents with identical headers by unique key tuples and report added, removed, and changed rows.
- [CSV add row number](/tools/csv-add-row-number): Prepend a 1-based row_number column of canonical integer strings.
- [CSV concat](/tools/csv-concat): Concatenate CSV documents that share identical headers, preserving document and row order.
- [CSV dedupe](/tools/csv-dedupe): Remove duplicate CSV data rows while preserving the first occurrence.
