ComfyUI Node

YK_Line loading

Batch your prompt list without the blank-line mess

By sittere·Created about a year ago·Updated about a year ago· 2
YK_Line loading
    • text_output
    • line_count
    • new_seed
    text_input
    enable_formattingtrue
    file_path
    file_name
    calculate_linestrue
    seed0

    The name is a lie, sort of - despite the "Loader" in the class, MultiTextLoader doesn't dump a whole file into your graph. It's a one-line-at-a-time prompt iterator. You hand it a text file (or a pasted block) where every line is one prompt, and it hands back a single line plus a "next please" counter, which is exactly the pattern you want when you're batch-generating from a list ChatGPT or Gemini wrote for you.

    That's the author's own use case, straight from the README: have an LLM reverse-engineer a pile of image ideas into a document, drop the document in, and generate one image per prompt. If you've ever tried this with a raw text file you know the problem the node is built around - LLM output is full of blank lines between paragraphs, which breaks naive line-per-prompt parsing. enable_formatting (on by default) strips whitespace off every line and drops the empties before the split happens. Past the blank-line problem it's a plain utility: pure stdlib, no models, no API keys, no dependencies.

    How it actually works

    The source is a single function, so the behavior is fully predictable. It looks for file_path + file_name joined together; if that file exists and has non-empty content it reads it (UTF-8 only), otherwise it silently falls back to text_input. Then it splits everything on newlines, applies the formatting cleanup, and picks one line with seed % line_count. new_seed is just seed + 1.

    The output you'll actually wire up is text_output - a STRING you feed into whatever text-encoder / CLIP input your workflow uses. line_count and new_seed exist to drive the loop.

    The seed trick (read this, it will save you a headache)

    The seed input here is not a sampler seed. It's a line index. Set it to 0 and you get line 1; set it to 50 and you get line 51 (modulo the total, so it wraps). If you feed it a random KSampler seed you'll hop to a random prompt, which is usually not what you meant. The intended loop is: start at 0, wire new_seed back into the seed input, and rerun for each image - that steps through your list in order. A couple of things to know:

    • Vanilla ComfyUI has no for-loop. The "for loop" from the README is really you bumping and re-running, or your own rerun wrapper. If you expect to press play once and get N images, this node alone won't do it.
    • calculate_lines controls whether line_count reports anything (returns the count) or just a 0. Turn it off if you're only using the count for display.
    • When the index passes the end of the list it wraps back to line 0, so an off-by-one loop silently repeats instead of erroring. That's usually fine - if you're batch of 10 vs 12 prompts, you'll just see repeats at the tail.

    Inputs that matter

    • file_path / file_name - point these at your prompt document. If either is empty or the file can't be read, the node quietly falls back to text_input instead.
    • text_input - the fallback source, or the whole source if you're not using a file.
    • enable_formatting - the blank-line stripper. Leave it on unless your prompts have meaningful line structure you want preserved.
    • seed - the line selector described above.

    Note the README also lists a "control_mode 种子控制模式" setting. It doesn't exist in the actual node - the README drifts a little here (and is written in Chinese; the pack is clearly built for a Chinese-speaking audience). The seed input is the only control you get, and it's enough.

    Install

    Via ComfyUI Manager, search for YK_Line (or "ComfyUI-YK_Line-loading") and install. Or the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sittere/ComfyUI-YK_Line-loading
    

    Restart ComfyUI. There's no requirements.txt - the node imports only Python stdlib plus ComfyUI itself, so there's nothing to go wrong at install time. It shows up under the custom category as "YK_Line loading".

    Gotchas worth knowing

    The biggest trap is silent fallback. The file read is wrapped in a bare except: pass, so a missing file, a wrong path, or - the one that bites the README's own target audience - a non-UTF-8 text file (say, a GBK-encoded Word export from Windows) all produce empty file_text, and the node just uses text_input without telling you. If your outputs look identical no matter what you put in the file, check the encoding and convert to UTF-8. Also remember this node picks one line per run - it's for one-prompt-per-line lists, not for loading a full multi-paragraph prompt. For that you'd want a plain text file reader instead.

    Categorycustom

    Inputs (6)

    NameTypeDefaultDescription
    text_inputSTRING
    enable_formattingBOOLEANtrue
    file_pathSTRING
    file_nameSTRING
    calculate_linesBOOLEANtrue
    seedINT00–18446744073709550000

    Outputs (3)

    NameTypeDescription
    text_outputSTRING
    line_countINT
    new_seedINT