Visit ComfyUI Online for ready-to-use ComfyUI environment
Reads text file content as string, supports UTF-8, EOF handling, useful for AI artists.
The ReadTextFile
node is designed to read the contents of a specified text file and return the data as a string. This node is particularly useful for AI artists who need to incorporate text data from external files into their workflows. It can read the entire file or a specific line, making it versatile for various use cases. The node handles file reading in UTF-8 format, ensuring compatibility with most text files. Additionally, it provides options to manage end-of-file (EOF) scenarios gracefully, either by ignoring non-existent lines or raising an error to alert you.
This parameter specifies the path to the text file you want to read. It can be an absolute or relative path. The default value is file.txt
. This parameter is crucial as it tells the node which file to read from.
This optional parameter determines which line of the file to read. If set to 0
, the entire file will be read and returned as a single string. If set to a positive integer, only that specific line number will be read. The default value is 0
.
This optional boolean parameter dictates the action to take if the specified line number does not exist in the file. If set to True
(default), the node will ignore the non-existent line and return an empty string. If set to False
, the node will raise an error to alert you.
The output is a string containing the contents of the text file. If a specific line number is provided, only that line will be returned. If the entire file is read, the output will be the full text content of the file.
line
parameter to 0
.line
parameter to the desired line number.on_eof
parameter to control how the node handles non-existent lines, which can be useful for error handling in your workflow.on_eof
to True
to ignore this error.© Copyright 2024 RunComfy. All Rights Reserved.