Extracting text from File
Last updated
Last updated
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:
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.
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.
The calculated field uses the following expression to extract the text from the file in the same record:
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.
The result looks like this:
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.