> 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/convert-text-to-datatable.md).

# convert-text-to-datatable

## Description

<mark style="color:purple;">`convert-text-to-datatable`</mark> *adaptor converts* [*DSV text*](https://en.wikipedia.org/wiki/Delimiter-separated_values) *into a datatable using specified separators to denote the split for columns and new rows.*

The default character used as column delimiter is `,` (comma), this can be changed by setting the `delimiter` input. The default character used as row delimiter is (LF), this can be changed by setting the `newline` input.

## Inputs

**`csv`**\
Type: `text`\
Required: Yes\
The text to be converted to datatable.

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

**`newline`**\
Type: `text`\
Required: No\
Character used as line separator. If unspecified, defaults to  (newline).

**`trim`**\
Type: `boolean`\
Required: No\
Specifies whether to ignore whitespace characters immediately around the separator. If unspecified, defaults to `True`.

**`columns`**\
Type: `list`\
Required: No\
List of column names to be added. If unspecified, first row of the file will be used as column names.

## Outputs

**`data`**\
Type: `datatable`\
A datatable.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`text`:

```
Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar
```

#### Outputs:

`data`:

| Year | Make    | Model  |
| ---- | ------- | ------ |
| 1997 | Ford    | E350   |
| 2000 | Mercury | Cougar |

-> Converted CSV text to a datatable.

### Example 2: Convert text with vertical bar as value separator and semicolon as row separator.

#### Inputs:

`text`:

```
Year|Make|Model;1997|Ford|E350;2000|Mercury|Cougar;
```

`delimiter`: `|` ([vertical bar](https://en.wikipedia.org/wiki/Vertical_bar))

`newline`: `;` (semicolon)

#### Outputs:

* `data`:

  | Year | Make    | Model  |
  | ---- | ------- | ------ |
  | 1997 | Ford    | E350   |
  | 2000 | Mercury | Cougar |

-> Converted text with vertical bar as a value separator and semicolon as a row separator to a datatable.

### Example 3: Text without header line.

#### Inputs:

`text`:

```
1997,Ford,E350
2000,Mercury,Cougar
```

`columns`:

* Column1
* Column2
* Column3

#### Outputs:

`data`:

| Column1 | Column2 | Column3 |
| ------- | ------- | ------- |
| 1997    | Ford    | E350    |
| 2000    | Mercury | Cougar  |

-> Converted text without header line to a datatable.

## Use Cases

* Add small reference dataset into a workflow rather than adding a file or user-provided input.
