# 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`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/export-to-csv-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
