# CSV and TSV

This example loads a client-side CSV file with named columns, then exports the rows as escaped tab-separated text. Start the server and run the commands where `./coordinator` is available.

## Create, import and inspect

Use a fresh destination table for this example:

```sh
printf 'id,name\n1,Ada\n2,Grace\n' > people.csv
./coordinator client --database data --query "CREATE TABLE people(id UInt64,name String)" > /dev/null
./coordinator client --database data --query "INSERT INTO people FROM INFILE 'people.csv' FORMAT csv_with_names" > /dev/null
./coordinator client --database data --query "SELECT * FROM people ORDER BY id FORMAT tab_separated"
```

```text
1	Ada
2	Grace
```

## Headers and separators

CSV names headers match target columns by default. `csv_with_names_and_types` adds a type header. Plain csv is positional, so its field order must match the selected destination columns.

Use `SETTINGS csv_separator=';'` for a different delimiter, before the INSERT FORMAT clause. Quoted CSV fields can contain delimiters and newlines; tab_separated instead uses escapes for control characters.

## Several files and compression

INFILE infers decompression from recognized suffixes such as `.gz` and `.zst`. Each matched file is decoded separately, preserving its own header. A malformed file cancels the whole INSERT.

See [CSV](https://coordinatordb.com/docs/reference/formats/csv/csv) and [TabSeparated](https://coordinatordb.com/docs/reference/formats/tab-separated/tab-separated) for NULL markers, quoting, escapes and settings.
