Nodes/comfyui-easyapi-nodes/ReadTextFromLocalFile
ComfyUI Node

ReadTextFromLocalFile

Pull a caption or prompt straight off disk

By lldacing·Created 3 years ago·Updated 8 months ago· 96
ReadTextFromLocalFile
    • text
    text_path

    Plain and useful: give it a path, get back the text inside that file as a STRING. No transformation, no parsing - this is the read half of this pack's local-file-saving nodes, for pulling a caption, a saved prompt, or any plain-text sidecar file back into the graph.

    The inputs and outputs that matter

    • text_path (STRING) - the full path to the file.
    • text (STRING) - its contents.

    That's the entire node. It reads whatever is at the path and hands the raw text back.

    Where you'd actually use it

    The obvious pairing is a dataset-style loop: use LoadLocalFilePath to list a folder of .txt caption files, run the list through ForEachOpen (or ListUnWrapper), and use this node to pull each file's contents in as a prompt or caption for the rest of the graph. It's also the natural counterpart to this pack's SaveTextToLocalFile and SaveTextToFileByImagePath - write with one of those, read back with this one.

    How to install it

    Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
    cd comfyui-easyapi-nodes
    pip install -r requirements.txt
    

    Restart ComfyUI. No models, nothing heavy.

    Common issues & troubleshooting

    A missing or mistyped path is the most common failure. text_path wants a full filesystem path, not something relative to ComfyUI's input folder - double-check it against LoadLocalFilePath's paths output rather than typing it by hand, especially if you're batch-processing.

    Non-text files will fail rather than produce garbled output. If the file at that path isn't plain UTF-8 text - a stray binary file, an oddly-encoded export from another tool - expect a decode error. This is a straightforward text reader, not a format-sniffing one, so keep it pointed at actual .txt-style files.

    An empty file isn't an error, it's just an empty string. Downstream nodes that assume text always has content (a prompt encoder, say) won't complain about a missing file the way you'd expect - they'll just silently run on nothing. If a step further down the graph is behaving oddly, checking whether the source .txt file is actually empty is worth doing before assuming the reader itself is broken.

    Whitespace comes along for the ride. A trailing newline that most text editors add automatically will show up in text exactly as written - usually harmless for a prompt, but worth knowing if you're feeding the result into something that compares strings exactly or builds a filename from it, where a stray \n at the end can cause a mismatch that's genuinely confusing to spot by eye.

    CategoryEasyApi/Utils

    Inputs (1)

    NameTypeDefaultDescription
    text_pathSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING