split (to LIST)
Split a CSV Prompt Into a LIST You Can Actually Index
- LIST
Sometimes your data shows up in the wrong shape. You've got "cyberpunk, neon, rain" in one string and you need it as three separate strings you can grab by position. split (to LIST) is Python's str.split() wrapped in a node: cut the string at a separator you specify, get back a LIST you can index, sort, count, or hand to the pack's other list tools.
How it works
It's part of StableLlama's Basic data handling pack - the zero-dependency collection of plain Python string/list/math utilities. The function is a straight pass-through to str.split(sep, maxsplit).
Three inputs, and only two really matter:
string(required) - what you're splitting.sep(optional, default"") - the separator. Here's the subtle bit: an empty string is treated as no separator, which in Python means "split on any run of whitespace." So leave it blank and"a b c"becomes three items. Put a comma in and you get CSV-style splitting.maxsplit(optional INT, default-1) - how many splits to do at most.-1means unlimited. Set it to1and"a,b,c"becomes["a", "b,c"]- useful when you only want to carve off the first field and keep the rest intact.
The output is a single LIST of strings, named LIST. Since the pack treats a LIST as one variable, the entire split result arrives as a unit - that's what you want for index-based access (first tag, last tag) or for passing the whole thing somewhere that takes a LIST.
What it's actually for
- Parsing comma-separated tags from a metadata string or a CSV row.
- Splitting a prompt by a delimiter so you can reorder or swap parts before feeding it downstream.
- Carving config values out of a
key=value;key2=value2blob.
There's also a split (from data list) variant in the pack that returns the parts as a data list (each item processed individually) rather than one LIST. If you find yourself fighting the wire types, that's the other half of the pair.
Installing it
Search "Basic data handling" in ComfyUI Manager and restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart and you're set. No dependencies, no models - the whole pack is pure Python.
Gotchas
The empty-sep-means-whitespace behavior is the one that bites. People type a space into sep, get one whitespace run collapsed differently than expected, and blame the node. Leave sep blank for whitespace splitting, or be deliberate about your delimiter. Also remember maxsplit is "splits," not "resulting pieces" - maxsplit=1 gives you two pieces. That off-by-one has caused more than one head-scratch.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| sepopt | STRING | — | |
| maxsplitopt | INT | -1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |