# CSV distinct values

`csv-distinct-values` · version 1.0.0 · CSV & tables · free, no key needed

List distinct exact values of one CSV column in first-seen order.

**Use when you need to: csv distinct values · unique csv column values · distinct column.**

## Supported

- csv distinct values
- unique csv column values
- distinct column

## Not supported

- sort
- case fold
- trim
- numeric unique

## Behavior

- The first CSV record is the header row.
- Duplicate and empty header names are rejected.
- column is an exact header name.
- values lists first-seen exact cell strings from that column, including empty string if present.
- No trimming, case folding, type coercion, or other normalization is performed.
- A header-only or empty-data document yields values [].
- An empty document with a column request is invalid.

## Input

- `csv` (string, required): max length 256000
- `column` (string, required): min length 1; max length 256

## Output

- `values` (array of string, required)
- `rows_in` (integer, required)
- `distinct` (integer, required)

## Limits

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

## Example

Request input:

```json
{
  "csv": "k\na\nb\na\n",
  "column": "k"
}
```

Response:

```json
{
  "result": {
    "values": [
      "a",
      "b"
    ],
    "rows_in": 3,
    "distinct": 2
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "csv-distinct-values",
  "version": "1.0.0",
  "input": {
    "csv": "k\na\nb\na\n",
    "column": "k"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-distinct-values/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"csv":"k\na\nb\na\n","column":"k"}'
```

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

### CLI

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

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

## Related tools

- [CSV abs integer column](/tools/csv-abs-integer-column): Replace every data cell in a named CSV column with the absolute value of a canonical integer.
- [CSV clamp integer column](/tools/csv-clamp-integer-column): Clamp every data cell in a named CSV column to optional canonical integer min and max bounds.
- [CSV filter equals](/tools/csv-filter-equals): Keep CSV data rows whose named column equals an exact string.
- [CSV scale integer column](/tools/csv-scale-integer-column): Multiply every data cell in a named CSV column by a canonical integer factor.
- [CSV schema check](/tools/csv-schema-check): Validate a CSV document against an ordered column list and per-column string constraints.
- [CSV split column](/tools/csv-split-column): Split one CSV column on an exact separator into uniquely named columns.
