ComfyUI > Nodes > TrentNodes > Text File Line Loader

ComfyUI Node: Text File Line Loader

Class Name

CUN_TextFileLineLoader

Category
Trent/Utilities
Author
TrentHunter82 (Account age: 0days)
Extension
TrentNodes
Latest Updated
2026-03-20
Github Stars
0.03K

How to Install TrentNodes

Install this extension via the ComfyUI Manager by searching for TrentNodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter TrentNodes in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Text File Line Loader Description

CUN_TextFileLineLoader reads text files line-by-line, preserving state for efficient data access.

Text File Line Loader:

The CUN_TextFileLineLoader is a utility node designed to facilitate the reading of text files line by line, offering a streamlined way to access and process text data. This node is particularly useful for AI artists and developers who need to handle large text files efficiently, allowing them to focus on creative tasks rather than technical file handling. By leveraging this node, you can automatically or manually retrieve specific lines from a text file, making it ideal for applications that require sequential or indexed access to text data. The node ensures that the file's state is preserved between sessions, maintaining the current line index for seamless continuity. This feature is especially beneficial for projects that involve iterative processing or batch operations on text data, as it minimizes the risk of data loss or repetition. Overall, the CUN_TextFileLineLoader enhances productivity by simplifying text file management and providing a reliable mechanism for accessing text content.

Text File Line Loader Input Parameters:

file_path

The file_path parameter specifies the location of the text file you wish to load. It is crucial for the node to access the correct file, and the path must be valid and accessible. If the file path is incorrect or the file does not exist, the node will not be able to load the file, resulting in an error. There are no specific minimum or maximum values for this parameter, but it must be a valid string representing the file path.

label

The label parameter is used to identify the text batch being processed. This label is essential for maintaining the state of the file loading process, allowing the node to remember the last accessed line between sessions. It acts as a unique identifier for the text file being processed, ensuring that the correct state is loaded when the node is used again. There are no specific constraints on the value of this parameter, but it should be a meaningful string that helps you identify the text batch.

mode

The mode parameter determines how lines are retrieved from the text file. It can be set to either automatic or index. In automatic mode, the node retrieves the next line sequentially, while in index mode, it retrieves a specific line based on the provided index. This parameter allows you to control the line retrieval process, making it flexible for different use cases. The default value is automatic.

index

The index parameter is used when the mode is set to index. It specifies the line number to be retrieved from the text file. This parameter is particularly useful when you need to access a specific line directly. The index is zero-based, meaning that an index of 0 corresponds to the first line of the file. There are no explicit minimum or maximum values, but the index should be within the bounds of the file's line count to avoid errors.

Text File Line Loader Output Parameters:

line

The line output parameter provides the content of the retrieved line from the text file. This output is crucial for any subsequent processing or analysis tasks you wish to perform on the text data. The line content is returned as a string, and its value depends on the current state of the file loading process and the specified mode and index.

line_count

The line_count output parameter indicates the total number of lines in the text file. This information is valuable for understanding the size of the text data and for making decisions about further processing steps. It helps you determine the bounds for the index parameter and provides context for the retrieved line.

Text File Line Loader Usage Tips:

  • Ensure that the file_path is correct and accessible to avoid errors related to file loading.
  • Use meaningful label values to easily identify and manage different text batches, especially when working with multiple files.
  • Choose the appropriate mode based on your needs: use automatic for sequential processing and index for direct access to specific lines.
  • When using index mode, verify that the index is within the bounds of the file's line count to prevent out-of-bounds errors.

Text File Line Loader Common Errors and Solutions:

File not found at path: <file_path>

  • Explanation: This error occurs when the specified file path is incorrect or the file does not exist at the given location.
  • Solution: Double-check the file_path parameter to ensure it is correct and that the file is accessible.

File is empty.

  • Explanation: This warning indicates that the text file does not contain any lines to read.
  • Solution: Verify that the file is not empty and contains the expected text data.

Cannot get line by index from an empty file.

  • Explanation: This warning occurs when attempting to retrieve a line by index from an empty file.
  • Solution: Ensure that the file contains data before attempting to access lines by index.

Index <safe_idx> is out of bounds for file with <line_count> lines.

  • Explanation: This error occurs when the specified index is outside the valid range of line numbers in the file.
  • Solution: Adjust the index parameter to be within the range of 0 to line_count - 1.

Text File Line Loader Related Nodes

Go back to the extension to check out more related nodes.
TrentNodes
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Text File Line Loader