> For the complete documentation index, see [llms.txt](https://cgps.gitbook.io/data-flo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cgps.gitbook.io/data-flo/reference-guide/export-to-csv-file.md).

# export-to-csv-file

## Description

<mark style="color:purple;">`export-to-csv`</mark> *adaptor exports a datatable to a CSV file.*

Exports a datatable as a file with a specified delimiter (CSV, TSV, etc.), which allows for downstream use of the processed data for applications outside of Data-flo.

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable to be exported.

**`delimiter`**\
Type: `text`\
Required: No\
Character used as column delimiter. Defaults to "," (comma).

**`columns`**\
Type: `list`\
Required: No\
A list of columns to be exported to the CSV file. If unspecified, all columns will be exported.

**`output file name`**\
Type: `text`\
Required: No\
The name of the output file. If unspecified, defaults to `data.csv`.

## Outputs

**`file`**\
Type: `file`\
A file in CSV format.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |

`delimiter:` *null (empty)*

`columns:` *null (empty)*

`output file name:` *null (empty)*

#### Outputs:

`file`: data.csv

```
id, code, name
1, GB, United Kingdom
2, TR, Turkey
3, US, United States
```

-> Exported datatable to the CSV file `data.csv`.

### Example 2: Export datatable with a specified delimiter and file name.

#### Inputs:

`data:`

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |

`delimiter:` ;

`columns:` *null (empty)*

`output file name:` country.csv

#### Outputs:

`file`: country.csv

```
id; code; name
1; GB; United Kingdom
2; TR; Turkey
3; US; United States
```

-> Exported datatable to the CSV file `country.csv` with `;(semicolon)` as the delimiter.

### Example 3: Export only selected columns.

#### Inputs:

`data:`

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |

`delimiter:` ,

`columns:`

1. id
2. name

`output file name:` country.csv

#### Outputs:

`file`: country.csv

```
id, name
1, United Kingdom
2,Turkey
3, United States
```

-> Exported columns `id` and `name` from the datatable to the CSV file `country.csv`.
