# CSV rows filter numeric

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

Filters RFC 4180 CSV rows by an exact column or ratio comparison and returns the complete CSV.

**Use when you need to: filter csv by numeric ratio · filter CSV rows by number · keep rows above a threshold.**

## Decide before calling

Read the [versioned contract](/v1/tools/csv-rows-filter-numeric/versions/1.0.0) and the supported scope below. Reuse `csv-rows-filter-numeric@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-rows-filter-numeric@1.0.0` for filter csv by numeric ratio. 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 by numeric ratio
- filter CSV rows by number
- keep rows above a threshold
- select records by percentage of two columns
- compare exact decimal CSV column
- filter table where ratio is less than value

## Not supported

- does not evaluate arbitrary formulas
- does not infer CSV dialects

## Behavior

- Parse and serialize RFC 4180 records with CRLF output and a required unique header.
- Provide either column alone, or numerator_column and denominator_column together; percentage defaults to false.
- Comparisons use exact signed integer decimal arithmetic without rounding.
- The header and selected original rows and fields remain byte-value equivalent after RFC 4180 serialization.
- Strip one leading UTF-8 BOM before parsing the header.

## Input

- `csv` (string, required): min length 1; max length 16384
- `column` (string, optional): min length 1; max length 64
- `numerator_column` (string, optional): min length 1; max length 64
- `denominator_column` (string, optional): min length 1; max length 64
- `percentage` (boolean, optional)
- `comparison` (one of "gt", "gte", "lt", "lte", "eq", "ne", required)
- `threshold` (string, required): min length 1; max length 64
- `empty_policy` (one of "error", "exclude", "zero", required)
- `non_numeric_policy` (one of "error", "exclude", "zero", required)
- `division_by_zero_policy` (one of "error", "exclude", "zero", required)

## Output

- `csv` (string, required): max length 16384
- `rows_in` (integer, required): min 0; max 500
- `rows_out` (integer, required): min 0; max 500
- `standard_version` (constant "RFC 4180 + IEEE 754-2019 4.3", required)

## Limits

- max input bytes: 16384
- max rows: 500
- max columns: 40
- max cell bytes: 256
- max output bytes: 16384
- max decimal digits: 100

## Example

Request input:

```json
{
  "csv": "a,note\r\n2,\"x,y\"\r\n0,z\r\n",
  "column": "a",
  "comparison": "gt",
  "threshold": "1",
  "empty_policy": "error",
  "non_numeric_policy": "error",
  "division_by_zero_policy": "error"
}
```

Response:

```json
{
  "result": {
    "csv": "a,note\r\n2,\"x,y\"\r\n",
    "rows_in": 2,
    "rows_out": 1,
    "standard_version": "RFC 4180 + IEEE 754-2019 4.3"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "csv-rows-filter-numeric",
  "version": "1.0.0",
  "input": {
    "csv": "a,note\r\n2,\"x,y\"\r\n0,z\r\n",
    "column": "a",
    "comparison": "gt",
    "threshold": "1",
    "empty_policy": "error",
    "non_numeric_policy": "error",
    "division_by_zero_policy": "error"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-rows-filter-numeric/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"csv":"a,note\r\n2,\"x,y\"\r\n0,z\r\n","column":"a","comparison":"gt","threshold":"1","empty_policy":"error","non_numeric_policy":"error","division_by_zero_policy":"error"}'
```

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

### CLI

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

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

## Related tools

- [CSV filter compare](/tools/csv-filter-compare): Filter ASCII CSV rows by string/decimal comparison; requires CRLF records, rejects LF-only and non-ASCII input.
- [CSV column compute](/tools/csv-column-compute): Appends an exact rounded arithmetic column to RFC 4180 CSV and returns the complete CSV.
- [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.
- [Table count distinct check](/tools/table-count-distinct-check): Check a claimed COUNT(DISTINCT) and optional distinct-value list over JSON rows; returns the first mismatch.
- [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 filter equals](/tools/csv-filter-equals): Keep CSV data rows whose named column equals an exact string.
