# CSV merge columns

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

Join named CSV columns with an exact separator into one column.

**Use when you need to: csv merge columns · join csv columns with separator · combine csv columns into one.**

## Supported

- csv merge columns
- join csv columns with separator
- combine csv columns into one

## Not supported

- skip empty parts
- trim cells before joining
- regex join
- infer target name
- fuzzy matching
- read files
- fetch urls

## Behavior

- The first CSV record is the header row. An empty document is rejected; a header-only document yields merged headers and zero data rows.
- columns names 2 to 16 unique existing headers exactly. separator is a literal string of at most 16 UTF-16 code units and may be empty.
- Each output cell is columns.map(c => cell[c]).join(separator) with no trimming, skipping of empties, case folding, or type coercion.
- Source columns are dropped. into is inserted at the original index of columns[0] after earlier source columns are removed. into may equal a source column name but must not equal a remaining non-source header.
- The first output header 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 2; max items 16; each min length 1; each max length 256
- `separator` (string, required): max length 16
- `into` (string, required): min length 1; max length 256

## Output

- `csv` (string, required)

## Limits

- max input bytes: 256000
- max data rows: 5000
- max columns: 256
- max header name bytes: 256
- min merge columns: 2
- max merge columns: 16
- max separator chars: 16
- max output bytes: 256000

## Example

Request input:

```json
{
  "csv": "id,first,last\n1,Ada,Lovelace\n2,Grace,Hopper\n",
  "columns": [
    "first",
    "last"
  ],
  "separator": " ",
  "into": "name"
}
```

Response:

```json
{
  "result": {
    "csv": "id,name\n1,Ada Lovelace\n2,Grace Hopper\n"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "csv-merge-columns",
  "version": "1.0.0",
  "input": {
    "csv": "id,first,last\n1,Ada,Lovelace\n2,Grace,Hopper\n",
    "columns": [
      "first",
      "last"
    ],
    "separator": " ",
    "into": "name"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/csv-merge-columns/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"csv":"id,first,last\n1,Ada,Lovelace\n2,Grace,Hopper\n","columns":["first","last"],"separator":" ","into":"name"}'
```

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

### CLI

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

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

## Related tools

- [CSV split column](/tools/csv-split-column): Split one CSV column on an exact separator into uniquely named columns.
- [CSV fill defaults](/tools/csv-fill-defaults): Replace empty cells in named CSV columns with exact default strings.
- [CSV anti join](/tools/csv-anti-join): Keep left CSV rows whose exact key tuples do not appear in the right document.
- [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.
- [CSV drop columns](/tools/csv-drop-columns): Drop named CSV columns and keep the remaining columns in original header order.
