# Text File Read

The **TextFileRead** function reads the contents of text files.

It can read delimited files, such as CSV files, to return file content field-by-field.

***

### Properties <a href="#properties" id="properties"></a>

#### File path <a href="#file-path" id="file-path"></a>

The path to the file to be read.

#### Encoding <a href="#encoding" id="encoding"></a>

The encoding type to use when reading from the file.

Options:

* **Default**
* **ANSI**
* **ASCII**
* **EBCDIC**
* **Mac**
* **OEM**
* **Unicode**
* **UTF8**

The 'Default' option is the encoding used in your operating system.

#### Return options <a href="#return-options" id="return-options"></a>

The way to read the file and return the content.

Options:

* **Line by line**: Returns each line's contents in a loop. If you have defined fields, each field is returned by the function and can be accessed in the loop.
* **List of lines**: Returns the entire file, but as a list. Each list member represents one line from the file. If you use a [ForEach](https://docs.linx.software/reference/plugins/linx/content/foreach) function to loop the list, you can access all fields separately in the loop.
* **Complete**: Reads the entire file and returns it as one string.

#### Fields <a href="#fields" id="fields"></a>

Only displayed if **Return options** is set to 'Line by line'. This property allows for importing of delimited files.

You can define the fields manually or by importing a sample file.

If you define fields, the function can return each field separately.

Click **...** to open the **Fields Editor**.

<figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-c7177696833d1d70d0588b7486cfbbb9699a8968%2Ffileeditor.png?alt=media" alt="FileEditor"><figcaption></figcaption></figure>

#### Fields Editor

**File Format**

Select one of:

* Comma Delimited
* Tab Delimited
* Custom Delimited - when selected, add the delimiter in the provided field
* Fixed length

**Text Qualifier**

Select one of:

* "
* '
* None

**Lines to skip**

**Header**

The number of header lines to ignore in the file.

**Footer**

The number of footer lines to ignore in the file.

**Define Fields**

Click **LOAD FIELDS FROM FILE** to load the fields from a file, which you can then define:\
provide the **Name**, **Type** and **Current Format** (for 'DateTime' type) of each field.\
If you selected 'Fixed length' as the **File format**, enter the **Length** for each field.

Select **Skip** for fields that you don't want to use.

**Review configuration**

Click **LOAD SAMPLE DATA** to load data from a file:

* Under the **Text** tab, the original content will display.
* Under the **Formatted** tab, the content will display as per the **Defined fields** configuration.

***

## Links <a href="#links" id="links"></a>

[Code page](http://en.wikipedia.org/wiki/Code_page)

[Transformations of Unicode Code Points](https://docs.microsoft.com/en-us/globalization/encoding/transformations-of-unicode-code-points)
