# import-from-csv-file

## Description

<mark style="color:purple;">`import-from-csv-file`</mark> *adaptor imports data from a CSV file and converts to a datatable*.

The adaptor can ingest data from an input file that uses comma separated values, tab separated values, or other similar formats.

## Inputs

**`file`**\
Type: `file`\
Required: Yes\
A file containing [Comma-separated values](https://en.wikipedia.org/wiki/Comma-separated_values) or delimited text.

**`encoding`**\
Type: `text`\
Required: No\
The character encoding of the input `file`. If unspecified, defaults to `utf8`.

**`delimiter`**\
Type: `text`\
Required: No\
Character used as column delimiter. 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.

**`column names`**\
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 containing the imported data.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`file` : country.csv

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

`encoding` : *null (empty)*

`delimiter` : *null (empty)*

`newline` : *null (empty)*

`trim` : *null (empty)*

`column names` : *null (empty)*

#### Outputs:

`file`:

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

-> Imported the CSV file `country.csv` into Data-flo.

### &#x20;Example 2: Import CSV file with a semicolon delimiter.

#### Inputs:

`file` : country.csv

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

`encoding` : *null (empty)*

`delimiter` :  *; (semicolon)*

`newline` : *null (empty)*

`trim` : *null (empty)*

`column names` : *null (empty)*

#### Outputs:

`file`:

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

-> Imported the CSV file `country.csv` with semicolon delimiter into Data-flo.

## Use Cases

* Pulling in ‘reports’ that get updated online.


---

# 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/import-from-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.
