> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemtipsandtricks/tips-and-tricks/extracting-text-from-file.md).

# Extracting text from File

A `.txt` file is one of the most basic file formats for storing text. Extracting text from a `.txt` file is straightforward because it contains plain text without formatting. Unlike extracting text from a Word or PDF file, extracting from `.txt` can be done with an expression instead of a process node.

The following expression will extract the text from the file:&#x20;

```
Base64ToText(ToBase64([Input.Files.File01]))
```

In the above example, `[Input.Files.File01]` represents a text file. This file is first encoded as Base64 text and then converted into a text string usable in the application.

### Example

In the data model, we have a list where we can store files for use in the application. This list holds two key fields: one field stores the actual `.txt` file, and the other is a calculated field that contains the extracted text.

<figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FC48kWE2HcGuWgFJovhAK%2Fimage.png?alt=media&amp;token=72579234-94eb-4ff3-b6af-8983dedf638a" alt=""><figcaption></figcaption></figure>

The calculated field uses the following expression to extract the text from the file in the same record:

```
Base64ToText(ToBase64([TextFromFile.Files.File]))
```

The next image shows you a basic interaction node that allows users to upload a `.txt` file and display its content. After uploading a `.txt` file a record with a text file is added to the database. A repeater is used to show the file on the left and the text content of the file on the right for each of the uploaded files.&#x20;

<figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FFJzxnW1vlMQzqhIkxCNN%2Fimage.png?alt=media&amp;token=bf51b184-8b76-424b-a06d-62e6ea9f81db" alt=""><figcaption></figcaption></figure>

The result looks like this:

<figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F4s0MxnRoeBR5oRNVO7p7%2Fimage.png?alt=media&amp;token=4d29ae0b-7a14-490b-9fb0-fc5c9acc3b56" alt=""><figcaption></figcaption></figure>

### Extracting text from other files

You can also extract text from `.docx` and `.pdf` files using the 'Extract Text from document' process node. You can read more about that process here: [Extract Text from Document](https://docs.wem.io/platform/wemmodeler/flowcharts/execute-process/changing-files#extract-text-from-document).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.wem.io/platform/wemtipsandtricks/tips-and-tricks/extracting-text-from-file.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
