# CSV filter compare

`csv-filter-compare` · version 1.0.0 · CSV & tables · free, no key needed

Filter ASCII CSV rows by string/decimal comparison; requires CRLF records, rejects LF-only and non-ASCII input.

**Use when you need to: filter CSV rows by column value · keep CSV records greater than a number · select rows with an exact field value.**

## Decide before calling

Read the [versioned contract](/v1/tools/csv-filter-compare/versions/1.0.0) and the supported scope below. Reuse `csv-filter-compare@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `csv-filter-compare@1.0.0` for filter CSV rows by column value. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- filter CSV rows by column value
- keep CSV records greater than a number
- select rows with an exact field value
- compare a CSV column as exact decimals
- remove rows equal to a literal
- filter comma separated data by threshold

## Not supported

- regular expression matching
- locale-aware collation
- floating-point or exponent notation

## Behavior

- The first RFC 4180 record is a unique, non-empty header and is always retained.
- Decimal comparison uses sign and digit strings exactly; it never converts to binary floating point.
- String ordering compares UTF-16 code units with JavaScript relational operators; no locale or normalization is applied.

## Input

- `csv` (string, required): min length 1; max length 16384
- `column` (string, required): min length 1; max length 256
- `operator` (one of "=", "!=", "<", "<=", ">", ">=", required)
- `literal` (string, required): max length 16384
- `comparison` (one of "decimal", "string", required)

## Output

- `csv` (string, required): max length 32768
- `rows_in` (integer, required): min 0; max 255
- `rows_out` (integer, required): min 0; max 255
- `standard_version` (constant "RFC 4180 (October 2005)", required)

## Limits

- max input bytes: 16384
- max rows: 256
- max columns: 32
- max iterations: 16384
- max output bytes: 32768

## Example

Request input:

```json
{
  "csv": "name,score\r\nAda,10\r\nBob,2",
  "column": "score",
  "operator": ">=",
  "literal": "10",
  "comparison": "decimal"
}
```

Response:

```json
{
  "result": {
    "csv": "name,score\r\nAda,10",
    "rows_in": 2,
    "rows_out": 1,
    "standard_version": "RFC 4180 (October 2005)"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "csv-filter-compare",
  "version": "1.0.0",
  "input": {
    "csv": "name,score\r\nAda,10\r\nBob,2",
    "column": "score",
    "operator": ">=",
    "literal": "10",
    "comparison": "decimal"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-filter-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"csv":"name,score\r\nAda,10\r\nBob,2","column":"score","operator":">=","literal":"10","comparison":"decimal"}'
```

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

### CLI

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

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

## Related tools

- [CSV filter pattern literal](/tools/csv-filter-pattern-literal): Filter ASCII CSV with literal contains/starts-with; requires CRLF records, rejects LF-only and non-ASCII input.
- [CSV dialect format](/tools/csv-dialect-format): Format string rows as CSV for an explicit dialect, quoting a one-field empty record when it can.
- [CSV to markdown table](/tools/csv-to-markdown-table): Render ASCII CSV with CRLF records as Markdown; rejects LF-only records and non-ASCII text.
- [Table aggregate check](/tools/table-aggregate-check): Check claimed COUNT/SUM/AVG/MIN/MAX results over JSON rows exactly (SQL nulls); returns the first mismatch.
- [CSV dialect parse](/tools/csv-dialect-parse): Parse CSV with an explicit dialect into string rows, keeping leading zeros and embedded breaks.
- [CSV filter equals](/tools/csv-filter-equals): Keep CSV data rows whose named column equals an exact string.
