Skip to content

Read Text From File

Overview

The Read Text From File node reads the contents of a local text file and stores it as a string variable within the workflow for further use in subsequent nodes.


Purpose

Use this node to import the text content of any accessible file into your workflow data for processing, transformation, or integration with other nodes.


Inputs

InputTypeDescription
Local FileTextThe full local path to the text file to be read. Example: C:\Temp\myfile.txt

Outputs

Output Variable NameDescription
FileTextContains the entire text content read from the specified file.

Execution Details

  1. Validation:

    • Validates that the Local File input is provided.
    • Checks if the file exists at the specified path.
  2. File Reading:

    • Reads the entire text content of the file using _fm.ReadTextToString(localFile).
  3. Output Handling:

    • Stores the resulting text in the FileText output variable.
    • Removes the Local File input from the task data after processing.
  4. Error Handling:

    • If the Local File input is missing or empty, the node fails with an appropriate error message.
    • If the file does not exist at the specified path, the node fails with an error message.
    • Any unhandled exceptions will result in node failure with the exception message returned.

Example Use Cases

  • Reading configuration files to extract runtime parameters.
  • Loading text templates or scripts for processing in later workflow nodes.
  • Importing data files for parsing and transformation within the workflow.

Notes

⚠️ Important:

  • Ensure the file path is accessible by the automation server or execution environment where this node runs.
  • Large files will be read entirely into memory; ensure this is appropriate for your use case.

Known Limitations

  • This node only reads text files. It does not support binary file reading.
  • It does not support encoding selection; it uses default system encoding unless _fm.ReadTextToString implementation specifies otherwise (please verify in SysFileMethods if necessary).

Tentech 2024