# split-column

## Description

<mark style="color:purple;">`split-column`</mark> *adaptor splits values in a column into a number of columns using a specified separator to determine where to make each split.*

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable containing the column to be split.

**`column name`**\
Type: `text`\
Required: Yes\
The name of the column to be split.

**`separator`**\
Type: `text`\
Required: Yes\
The separator text, or regular expression, which denotes the points at which each split should occur. The separator is treated a regular expression if it begins and ends with `/`.

**`new column names`**\
Type: `list`\
Required: Yes\
The list of columns to be added.

**`include column`**\
Type: `boolean`\
Required: No\
Specifies whether to include the original column in the output datatable. If unspecified, defaults to `True` (original column will be included).

## Outputs

**`data`**\
Type: `datatable`\
A datatable with new columns added.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | code  | name           |
| -- | ----- | -------------- |
| 1  | en-GB | United Kingdom |
| 2  | tr-TR | Turkey         |
| 3  | en-US | United States  |
| 4  | hi-IN | India          |

`column name:` code

`separator:` -

`new column names:` language

`include column:` *null(empty)*

#### Outputs:

`data`:

| id | code  | name           | language |
| -- | ----- | -------------- | -------- |
| 1  | en-GB | United Kingdom | en       |
| 2  | tr-TR | Turkey         | tr       |
| 3  | en-US | United States  | en       |
| 4  | hi-IN | India          | hi       |

-> Created a new column `language` with the values derived by splitting the values in `code` column on `-` separator. The original code column is included in the output by default.

### Example 2: Exclude the original column in the output.

#### Inputs:

`data:`

| id | code  | name           |
| -- | ----- | -------------- |
| 1  | en-GB | United Kingdom |
| 2  | tr-TR | Turkey         |
| 3  | en-US | United States  |
| 4  | hi-IN | India          |

`column name:` code

`separator:` -

`new column names:` language

`include column:` False

#### Outputs:

`data`:

| id | name           | language |
| -- | -------------- | -------- |
| 1  | United Kingdom | en       |
| 2  | Turkey         | tr       |
| 3  | United States  | en       |
| 4  | India          | hi       |

-> Created a new column `language` with the values derived by splitting the values in `code` column on `-` separator. The code column is included in the result by default.

## Use Cases

* Separate a date into components of year, month, and day.


---

# 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/split-column.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.
