Nodes/ComfyUI-DataSet/DataSet_TextFilesLoadFromList
ComfyUI Node

DataSet_TextFilesLoadFromList

Load Only the Text Files You Actually Ask For

By daxcay·Created 2 years ago·Updated about a year ago· 58
DataSet_TextFilesLoadFromList
    • TextFileNames
    • TextFileNamesWithoutExtension
    • TextFilePaths
    • TextFileContents
    TextFilePathsList

    DataSet_TextFilesLoadFromList is the picky sibling of DataSet_TextFilesLoad. Where the folder version sweeps up every .txt in a directory, this one takes an explicit list of file paths and loads only those - filtering down to .txt along the way. Same four outputs, same aligned lists, but you control exactly which files come in.

    You'd reach for it when you've already done the selecting. Say DataSet_PathSelector just told you which caption files are missing from your dataset - the natural next move is to load only those paths (once you've copied them over), process them, and write them back, rather than re-processing the whole folder. This node is the "I know exactly what I want" loader.

    Inputs and outputs

    The single input, TextFilePathsList, is a list of file paths - note it's forceInput, so it comes from another node's output rather than a widget you type. Only paths ending in .txt are processed; anything else in the list is silently skipped. That filter is worth remembering when a path list mysteriously comes back shorter than you fed in.

    Four list outputs, aligned by index:

    • TextFileNames - base names (photo_001.txt).
    • TextFileNamesWithoutExtension - photo_001, for feeding save nodes.
    • TextFilePaths - the full paths that were loaded.
    • TextFileContents - the caption text.

    How it works

    Same plain-Python file reading as its folder sibling, just driven by your list instead of a os.listdir(). It builds paths from the list, filters for .txt, reads each file, and returns the four lists. If a file is missing or unreadable, it prints to the console and skips it - no crash, no empty placeholder, just a log line and a shorter contents list.

    Installing

    Part of the ComfyUI-DataSet pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-DataSet.git
    cd ComfyUI-DataSet && pip install -r requirements.txt
    

    Restart ComfyUI and it lands under 🔶DATASET🔶. No models, nothing extra.

    Common issues

    The .txt-only filter is the main gotcha - if you feed it a list that's mostly .json or .md paths, you'll get back only the txt ones and no warning about the rest. And because the input is list-only, a common beginner stumble is trying to type a path into it as a widget; that won't work, so give it a real list from another node (or use the folder-based DataSet_TextFilesLoad if you don't have a list yet).

    Worth noting it's flagged as an output node, same as its sibling - running it completes the graph. In the bigger picture it's a small utility, but in a dataset pipeline where you want surgical control over which captions get loaded and edited, it's the node that lets you process a handful of files without touching the other 400. If that describes your workflow, this is the loader you want.

    Category🔶DATASET🔶

    Inputs (1)

    NameTypeDefaultDescription
    TextFilePathsListSTRING

    Outputs (4)

    NameTypeDescription
    TextFileNamesSTRING
    TextFileNamesWithoutExtensionSTRING
    TextFilePathsSTRING
    TextFileContentsSTRING