CSV RandomPicker (Advanced)
Same random pick, but now the count rolls too
- STRING
CSVRandomPicker picks a fixed number of items from a CSV by seed. CSVRandomPickerAdv is the same idea with the knobs that a real prompt system wants: the count itself can be random, and the separator that splits the pool doesn't have to be the separator that joins the result.
The advanced version shines when you're building variable-length prompts. With the basic node, "1 to 3 of these style tags" means three separate nodes. Here it's one node with min_count and max_count - roll once, get anywhere in that range, all reproducible from the seed.
How it works
Mechanically it's nearly identical to its little brother: split on input_separator, trim, seed a random.Random, and sample without replacement. The differences are all in the inputs. It first rolls a random count between min_count and max_count (both capped at the list length), then samples that many items, then joins them with output_separator. The split/join separation is the quiet star: you can keep a pool separated by raw commas and emit a prompt with ", " - or a | for a dynamic-prompts-style merge - without pre-processing your list.
One wrinkle the source is honest about: if min_count is bigger than max_count, it raises a hard error rather than guessing. The fix is one edit, but the error message is the kind that confuses people who thought both would just clamp.
Inputs and outputs
csv_string(STRING, multiline) - the pool.min_count/max_count(INT, 1–1000, defaults 1) - the range the count rolls within.input_separator(STRING, default,) - how the pool is split.output_separator(STRING, default,) - how the result is joined.seed(INT, default 0) - reproduces both the count roll and the pick.
One output: STRING.
Installing it
Part of ComfyUI-lhyNodes - same install as the rest of the pack:
- ComfyUI Manager → search
lhyNodes→ Install, restart. - Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/lihaoyun6/ComfyUI-lhyNodes.git
python -m pip install -r ComfyUI-lhyNodes/requirements.txt
Restart ComfyUI.
Where people get burned
The min_count > max_count error is the main gotcha, and it's a genuinely surprising one the first time you hit it - set 3/1 while fiddling and the whole graph refuses to queue. Also note the count roll happens before the sample and uses the same seeded RNG, so two different seed values that happen to land on the same count still give different items; everything is downstream of the one seed, which is the behavior you want for sharing. And same as the basic node, the pool lives in a widget - great for a couple dozen fragments, wrong tool for a thousand-line wildcard library.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| csv_string | STRING | apple,banana,cat,dog | — |
| min_count | INT | 11–1000 | — |
| max_count | INT | 11–1000 | — |
| input_separator | STRING | , | — |
| output_separator | STRING | , | — |
| seed | INT | 00–1125899906842624 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |