CSV Random Reader (Soze)
Roll a random row from your prompt CSV, on demand
- Column_1
- Column_2
- Column_3
- Column_4
- Column_5
- Column_6
- Column_7
- Column_8
- Column_9
- Column_10
- First_Row_Line
- Selected_Lines
- Selected_Count
- Total_Rows
- status
Prompt iteration usually means a big spreadsheet and a counter, which is great when you want every row exactly once. Sometimes you want the opposite: a random subject, style or setting pulled from a list, every run, for the serendipity. CSV Random Reader is the node for that. It reaches into a CSV file - or inline CSV text - grabs N random rows, and hands you the cells as outputs ready to feed a prompt builder or an enum switch.
It's the "lucky dip" sibling of the Soze pack's regular CSV Reader. Same CSV muscle, but instead of walking an index it rolls the dice.
How it works
Point it at a file via csv_filename_path (absolute path anywhere on disk, or a path relative to the pack's bundled py/csv_files folder), or paste CSV straight into csv_text - inline text always wins when it's non-empty. num_rows says how many rows to draw.
The controls that matter:
seed- the one to learn first.0means nondeterministic: the node re-runs every prompt, so each run is a fresh draw. Any other value seeds the RNG and makes the pick reproducible and cacheable (same CSV, same seed, same rows every time). Great for "this exact random set, again."allow_repeats- off by default, which uses unique sampling (clamped to the row count). On, and the same row can appear multiple times.skip_header- treat the first row as a header and don't return it.
Outputs are shaped for downstream text nodes: Column_1 through Column_10 (the first ten cells of the drawn row), plus First_Row_Line (the raw header row - useful when you have many columns and want to know what's what), Selected_Lines (all drawn rows as raw text), Selected_Count, Total_Rows, and status.
Where it earns its keep
Wire Column_1 into a prompt block and Column_2 into a sampler name feeding an Any Enum Switch, and you've got a random-prompt generator that's fully in-graph and versionable. Pair the seed output from a run with a fixed seed and you can replay a specific lucky draw. It's also just handy for QA: pull three random rows out of a 400-line prompt file to spot-check.
Where people get burned: only ten columns get named outputs - a wide CSV with fifteen columns means columns 11–15 are reachable only through Selected_Lines. And if your "random" results look suspiciously familiar, check the seed - 0 is random, anything else is deliberately deterministic. File-encoding hiccups on odd CSVs are handled (UTF-8 with a Windows-1252 fallback), but keep files plain UTF-8 and you'll never think about it.
Installing it
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
Or install "ComfyUI_Soze" via ComfyUI Manager and restart. No API keys, no model downloads - pure Python. It lives under the utils category as "CSV Random Reader (Soze)".
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| csv_filename_path | STRING | Absolute path or path relative to py/csv_files. Ignored if csv_text is non-empty. | |
| num_rows | INT | 11–10000 | How many rows to randomly pick. |
| csv_textopt | STRING | Inline CSV. Takes precedence over csv_filename_path when non-empty. | |
| seedopt | INT | 00–18446744073709550000 | 0 = nondeterministic; any other value seeds the RNG for reproducible picks. |
| allow_repeatsopt | BOOLEAN | false | If True, the same row may be picked more than once when num_rows exceeds available rows. |
| skip_headeropt | BOOLEAN | false | Skip the first row (treat it as a header). |
Outputs (15)
| Name | Type | Description |
|---|---|---|
| Column_1 | STRING | — |
| Column_2 | STRING | — |
| Column_3 | STRING | — |
| Column_4 | STRING | — |
| Column_5 | STRING | — |
| Column_6 | STRING | — |
| Column_7 | STRING | — |
| Column_8 | STRING | — |
| Column_9 | STRING | — |
| Column_10 | STRING | — |
| First_Row_Line | STRING | — |
| Selected_Lines | STRING | — |
| Selected_Count | INT | — |
| Total_Rows | INT | — |
| status | STRING | — |