# CSV select columns

`csv-select-columns` · version 1.0.0 · CSV & tables · free, no key needed

Select and reorder exact named columns from a complete CSV document.

**Use when you need to: csv select columns · select csv columns · reorder csv columns.**

## Supported

- csv select columns
- select csv columns
- reorder csv columns
- project csv columns

## Not supported

- rename columns
- match columns fuzzily
- infer types
- filter rows
- read files
- fetch urls

## Behavior

- columns must name unique existing headers exactly and determine output order.
- Cell strings, data-row order, and quoted CSV content are preserved semantically.
- No trimming, type coercion, renaming, or fuzzy column matching is performed.
- Header-only input is supported; an empty document is rejected because it has no header.
- The first selected column name may not begin with U+FEFF because it is ambiguous with a CSV byte-order mark.

## Input

- `csv` (string, required): max length 256000
- `columns` (array of string, required): min items 1; max items 256; each min length 1

## Output

- string

## Limits

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

## Example

Request input:

```json
{
  "csv": "name,city,note\nAda,London,\"hello, world\"\n",
  "columns": [
    "note",
    "name"
  ]
}
```

Response:

```json
{
  "result": "note,name\n\"hello, world\",Ada\n"
}
```

## How to call it

### MCP

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

```json
{
  "id": "csv-select-columns",
  "version": "1.0.0",
  "input": {
    "csv": "name,city,note\nAda,London,\"hello, world\"\n",
    "columns": [
      "note",
      "name"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-select-columns/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"csv":"name,city,note\nAda,London,\"hello, world\"\n","columns":["note","name"]}'
```

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

### CLI

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

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

## Related tools

- [CSV dedupe](/tools/csv-dedupe): Remove duplicate CSV data rows while preserving the first occurrence.
- [CSV drop columns](/tools/csv-drop-columns): Drop named CSV columns and keep the remaining columns in original header order.
- [CSV fill defaults](/tools/csv-fill-defaults): Replace empty cells in named CSV columns with exact default strings.
- [CSV group count](/tools/csv-group-count): Count CSV rows by exact named-column tuples in first-seen order.
- [CSV merge columns](/tools/csv-merge-columns): Join named CSV columns with an exact separator into one column.
- [CSV rename columns](/tools/csv-rename-columns): Rename CSV headers by an exact from/to mapping, preserving row cells and column order.
