Nodes/CSV Load One Line/CSVLoadOneLine
ComfyUI Node

CSVLoadOneLine

The ComfyUI node that eats your CSV one line at a time

By scofano·Created 10 months ago·Updated 5 months ago· 0
CSVLoadOneLine
    • first_column
    • second_column
    • third_column
    • full_line
    file_pathD:\ComfyUI_windows_portable\ComfyUI\output\prompts.csv
    seed-1

    Batch-running a hundred prompts is a classic ComfyUI pain. The community answer is usually a chunky pack like Inspire or was-node-suite, but every once in a while you want the dumbest possible tool that just works. That's this node: it reads the first line of a CSV file, splits it into up to three columns plus the full line, hands them to your graph as strings - and then permanently deletes that line from the file. Each run you queue, the file shrinks by one line and the next prompt surfaces. It's a ticketing system for your own ideas.

    There are two nodes in the scofano/comfy-csv-load-one-line pack, and you should care which one you drop in, because they behave very differently. This one, CSVLoadOneLine (shown in the node menu as "CSV Load One Line (Line Delete)"), mutates your file. Its sibling CSVLoadOneLineNoDelete reads by index and leaves the file alone. If "watching my CSV get consumed" sounds terrifying, you want the sibling.

    How it works

    The mechanism is refreshingly small - this whole pack is one file of stdlib Python, no dependencies. On every run the node opens your file with csv.reader using a semicolon (;) as the delimiter, takes the first line, and assigns columns 1–3 plus the full line as four STRING outputs. Missing columns come back as empty strings rather than errors, so a two-column file just gives you an empty third_column. It also prints the total line count to the ComfyUI console.

    Then the destructive part: it writes the remaining lines back over the file. That's the "one line at a time" loop - queue the workflow repeatedly and each run consumes the next prompt.

    The inputs and outputs that matter

    Two inputs, four outputs:

    • file_path (STRING) - the full path to your CSV. The default is a Windows path pointing at ComfyUI/output/prompts.csv, which is a decent hint at the intended use: drop a prompts file in your output folder and feed from there. Absolute paths are safer than relative ones, because os.path.isfile resolves relative paths against whatever directory ComfyUI happens to be running from.
    • seed (INT, default -1) - this is a trap worth knowing about. The delete variant never actually uses the seed value; it always reads line 0. The seed exists purely to force re-execution, since ComfyUI caches aggressively and won't re-run a node whose inputs look unchanged (see comfyui-node-plumbing.md). If you set it to increment or randomize, each run has a fresh input signature and the node fires. Leave it fixed and a cached workflow may sit there doing nothing.
    • Outputs: first_column, second_column, third_column, full_line - all STRING. The columns are what you'd wire into a CLIP Text Encode for a positive prompt, or into your negative prompt node. full_line gives you the raw line back if you want to parse it yourself downstream.

    Installing it

    Zero dependencies, zero model files - just the code. Through ComfyUI Manager, search "CSV Load One Line" and install, or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/scofano/comfy-csv-load-one-line
    

    Then restart ComfyUI. That's the whole install; the pyproject.toml declares dependencies = [], so there's nothing to pip-install and nothing to conflict with your other nodes. For a pack that runs arbitrary Python on import, stdlib-only is also a security point in its favor - there's nothing here you can't read in one sitting.

    Where people get burned

    • Semicolons, not commas. This is the big one. If your CSV is comma-delimited (the default in most tools), the entire line lands in first_column and second_column/third_column come back empty. Save your file with ; separators.
    • It deletes your data, permanently. One bad run, a crash mid-workflow, or an accidental queue and that prompt is gone. Back up the file first, and treat the read-only variant as the safe default.
    • BOMs. Excel's "CSV UTF-8" files start with a byte-order mark, and this node reads with plain utf-8 encoding, so your very first column on line one may carry a stray \ufeff. If the first prompt looks subtly corrupted, that's it.
    • Missing or empty file raises a ValueError ("File not found" / "CSV file is empty") rather than failing gracefully - so validate the path before you queue a long batch.

    If all you need is "read a line, don't destroy the file," the no-delete variant is the one you'll actually want in production. This one is for the batch-and-burn workflow, and it's genuinely good at that one job.

    CategoryCSV Load One Line

    Inputs (2)

    NameTypeDefaultDescription
    file_pathSTRINGD:\ComfyUI_windows_portable\ComfyUI\output\prompts.csv
    seedINT-1-1–18446744073709550000

    Outputs (4)

    NameTypeDescription
    first_columnSTRING
    second_columnSTRING
    third_columnSTRING
    full_lineSTRING