> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for the CustomSeparated format

# CustomSeparated

| Input | Output | Alias |
| ----- | ------ | ----- |
| ✔     | ✔      |       |

<h2 id="description">
  Description
</h2>

Similar to [Template](/reference/formats/Template/Template), but it prints or reads all names and types of columns and uses escaping rule from [format\_custom\_escaping\_rule](/reference/settings/formats#format_custom_escaping_rule) setting and delimiters from the following settings:

* [format\_custom\_field\_delimiter](/reference/settings/formats#format_custom_field_delimiter)
* [format\_custom\_row\_before\_delimiter](/reference/settings/formats#format_custom_row_before_delimiter)
* [format\_custom\_row\_after\_delimiter](/reference/settings/formats#format_custom_row_after_delimiter)
* [format\_custom\_row\_between\_delimiter](/reference/settings/formats#format_custom_row_between_delimiter)
* [format\_custom\_result\_before\_delimiter](/reference/settings/formats#format_custom_result_before_delimiter)
* [format\_custom\_result\_after\_delimiter](/reference/settings/formats#format_custom_result_after_delimiter)

<Note>
  It does not use escaping rules settings and delimiters from format strings.
</Note>

There is also the [`CustomSeparatedIgnoreSpaces`](/reference/formats/CustomSeparated/CustomSeparatedIgnoreSpaces) format, which is similar to [TemplateIgnoreSpaces](/reference/formats/Template/TemplateIgnoreSpaces).

<h2 id="example-usage">
  Example usage
</h2>

<h3 id="inserting-data">
  Inserting data
</h3>

Using the following txt file, named as `football.txt`:

```text theme={null}
row('2022-04-30';2021;'Sutton United';'Bradford City';1;4),row('2022-04-30';2021;'Swindon Town';'Barrow';2;1),row('2022-04-30';2021;'Tranmere Rovers';'Oldham Athletic';2;0),row('2022-05-02';2021;'Salford City';'Mansfield Town';2;2),row('2022-05-02';2021;'Port Vale';'Newport County';1;2),row('2022-05-07';2021;'Barrow';'Northampton Town';1;3),row('2022-05-07';2021;'Bradford City';'Carlisle United';2;0),row('2022-05-07';2021;'Bristol Rovers';'Scunthorpe United';7;0),row('2022-05-07';2021;'Exeter City';'Port Vale';0;1),row('2022-05-07';2021;'Harrogate Town A.F.C.';'Sutton United';0;2),row('2022-05-07';2021;'Hartlepool United';'Colchester United';0;2),row('2022-05-07';2021;'Leyton Orient';'Tranmere Rovers';0;1),row('2022-05-07';2021;'Mansfield Town';'Forest Green Rovers';2;2),row('2022-05-07';2021;'Newport County';'Rochdale';0;2),row('2022-05-07';2021;'Oldham Athletic';'Crawley Town';3;3),row('2022-05-07';2021;'Stevenage Borough';'Salford City';4;2),row('2022-05-07';2021;'Walsall';'Swindon Town';0;3)
```

Configure the custom delimiter settings:

```sql theme={null}
SET format_custom_row_before_delimiter = 'row(';
SET format_custom_row_after_delimiter = ')';
SET format_custom_field_delimiter = ';';
SET format_custom_row_between_delimiter = ',';
SET format_custom_escaping_rule = 'Quoted';
```

Insert the data:

```sql theme={null}
INSERT INTO football FROM INFILE 'football.txt' FORMAT CustomSeparated;
```

<h3 id="reading-data">
  Reading data
</h3>

Configure the custom delimiter settings:

```sql theme={null}
SET format_custom_row_before_delimiter = 'row(';
SET format_custom_row_after_delimiter = ')';
SET format_custom_field_delimiter = ';';
SET format_custom_row_between_delimiter = ',';
SET format_custom_escaping_rule = 'Quoted';
```

Read data using the `CustomSeparated` format:

```sql theme={null}
SELECT *
FROM football
FORMAT CustomSeparated
```

The output will be in the configured custom format:

```text theme={null}
row('2022-04-30';2021;'Sutton United';'Bradford City';1;4),row('2022-04-30';2021;'Swindon Town';'Barrow';2;1),row('2022-04-30';2021;'Tranmere Rovers';'Oldham Athletic';2;0),row('2022-05-02';2021;'Port Vale';'Newport County';1;2),row('2022-05-02';2021;'Salford City';'Mansfield Town';2;2),row('2022-05-07';2021;'Barrow';'Northampton Town';1;3),row('2022-05-07';2021;'Bradford City';'Carlisle United';2;0),row('2022-05-07';2021;'Bristol Rovers';'Scunthorpe United';7;0),row('2022-05-07';2021;'Exeter City';'Port Vale';0;1),row('2022-05-07';2021;'Harrogate Town A.F.C.';'Sutton United';0;2),row('2022-05-07';2021;'Hartlepool United';'Colchester United';0;2),row('2022-05-07';2021;'Leyton Orient';'Tranmere Rovers';0;1),row('2022-05-07';2021;'Mansfield Town';'Forest Green Rovers';2;2),row('2022-05-07';2021;'Newport County';'Rochdale';0;2),row('2022-05-07';2021;'Oldham Athletic';'Crawley Town';3;3),row('2022-05-07';2021;'Stevenage Borough';'Salford City';4;2),row('2022-05-07';2021;'Walsall';'Swindon Town';0;3)
```

<h2 id="format-settings">
  Format settings
</h2>

Additional settings:

| Setting                                                                                                                                         | Description                                                                                                                  | Default |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- |
| [input\_format\_custom\_detect\_header](/reference/settings/formats#input_format_custom_detect_header)                                          | enables automatic detection of header with names and types if any.                                                           | `true`  |
| [input\_format\_custom\_skip\_trailing\_empty\_lines](/reference/settings/formats#input_format_custom_skip_trailing_empty_lines)                | skip trailing empty lines at the end of file.                                                                                | `false` |
| [input\_format\_custom\_allow\_variable\_number\_of\_columns](/reference/settings/formats#input_format_custom_allow_variable_number_of_columns) | allow variable number of columns in CustomSeparated format, ignore extra columns and use default values for missing columns. | `false` |
