Nodes/WAS Node Suite v3/Load Text Line
ComfyUI Node Runs on cloud

Load Text Line

Prompts without a picker

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Load Text Line
    • line
    • lines
    • text
    • line_count
    • resolved_index
    file
    mode
    index0
    out_of_range
    skip_comment_linestrue
    seed0

    Load Text Line is the file version of a prompt switcher. You keep a text file of prompts (or negative prompts, or styles - one per line), and this node hands you one line at a time: the whole file, a specific line by index, or a line drawn from a seed. Feed the index from a counter and you step through a list run after run; feed it a seed and every run pulls a different random line you can reproduce. It turns a plain .txt into a batch-run schedule without any picker UI or extra files.

    It lives in WAS Node Suite (menu path WAS Suite/IO) - the big MIT toolkit whose v3 rewrite pushed past 450 nodes. If you've ever used its Text Random Line or the wildcard machinery, this is the more deliberate cousin: you control which line, not just "a random one".

    How it works

    The file menu scans ComfyUI's input and output folders (plus anything under paths.allow_read in config) for .txt, .csv, .tsv, .json, .jsonl, .md, .yaml, and .yml files, tagging entries [input] or [output] so two files of the same name stay distinguishable. Drop a new file in and it shows up within about five seconds. A file that's since been deleted gives empty text and a log note rather than killing the prompt - handy in long batch runs.

    Three modes decide what the main line output carries:

    • file - the whole file, lines joined back together. That's the one that feeds a prompt written across several lines.
    • index - the single line at index, counting from 0. Negative indexes count from the end (-1 is the last line), so it's safe to reach for the last line of a file whose length you don't know.
    • random - one line drawn by seed. Same seed + same file = same line, every time. Worth knowing the seed pins a position, not a line: add or remove a line in the file and the same seed silently gives you different text.

    skip_comment_lines is on by default, which drops any line whose first non-space character is # before anything is counted or numbered - so you can keep notes at the top of a prompt file without polluting your runs.

    What comes out

    The node hands you more than the one line:

    • lines - every line as an ARRAY, ready for Text List Get/Slice/Length.
    • text - the whole file as one string whatever the mode, for something like Text Find and Replace that wants the file as a whole.
    • line_count - how many lines survived comment filtering (0 for a file that couldn't be read).
    • resolved_index - which line number line actually came from after wrapping or clamping. When a counter is driving the index, this is your sanity check.

    The out_of_range setting matters more than it looks: wrap makes line 5 of a 3-line file read line 2 (good for cycling forever off a climbing counter), clamp sticks at the ends, empty returns nothing and keeps the graph running, and error stops the prompt - the right choice when running off the end means something upstream genuinely broke.

    Installing it

    Standard WAS install. ComfyUI Manager → search "WAS Node Suite v3", or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was-node-suite-comfyui.git
    

    Then restart ComfyUI. Needs ComfyUI 0.14.0+ and Python 3.10+; the pack adds no pip dependencies.

    Where people get burned

    The classic gotcha is the comment filter silently renumbering your file. If you're driving index from a counter and the file has # headers, every index after the header is off by however many comments you wrote - resolved_index output is there precisely so you can see it. The second is forgetting the file lives in input or output folders: for a file anywhere else on disk, the suite's Load Text File takes a typed path instead.

    CategoryWAS Suite/IO

    Inputs (6)

    NameTypeDefaultDescription
    fileCOMBOWhich text file to read. The menu lists .txt, .csv, .tsv, .json, .jsonl, .md, .yaml and .yml files in ComfyUI's input and output folders.
    modeCOMBOWhat the 'line' output carries. 'file' gives the whole file, every line joined back together, which is what feeds a prompt written across several lines. 'index' gives the single line at 'index', for stepping through a list with a counter. 'random' gives one line drawn by 'seed'. The 'lines' and 'text' outputs are the same in all three.
    indexINT0-99999999–99999999Which line 'index' mode takes, counting from 0, so 0 is the first line. -1 is the last line, -2 the one before it. Read only in 'index' mode. What happens past either end is 'out_of_range'.
    out_of_rangeCOMBOWhat an index past either end does: 'wrap' starts from the other end, 'clamp' sticks at the first or last line, 'empty' gives nothing, 'error' stops the prompt.
    skip_comment_linesBOOLEANtrueWhether lines whose first non-space character is '#' are dropped before anything is counted or numbered. On by default, so the indexes skip notes.
    seedINT00–18446744073709550000Which line 'random' mode draws. The same seed and the same file always give the same line; change it to draw a different one. The seed pins a position rather than a line, so adding or removing a line in the file, or changing skip_comment_lines, makes the same seed produce different text. Read only in 'random' mode.

    Outputs (5)

    NameTypeDescription
    lineSTRINGWhat the chosen mode selected: the whole file on 'file', one line on 'index' and 'random'. Empty when the file could not be read or holds no line to select.
    linesARRAYEvery line of the file on one wire, for Text List Slice, Text List Get, Text List Length and Text List to Strings. Comment lines are absent while skip_comment_lines is on.
    textSTRINGThe whole file as one string, the same lines joined with line breaks, whatever the mode. Wire this into Text Random Line or Text Find and Replace to work on the file as a whole.
    line_countINTHow many lines the file has, after comment lines are dropped. 0 for an empty file and for one that could not be read.
    resolved_indexINTWhich line number the 'line' output really came from, after wrapping or clamping, counting from 0. -1 in 'file' mode and whenever no single line was selected. Worth watching when a counter drives the index or a seed drives the draw.