CGA_ExtractFromList
Pull one item out of any list — the glue node for batch loops
- input_data
- *
ComfyUI gets clumsy the moment a node hands you a list and you only want one item from it. Maybe it's a batch of images and you want frame 12, or a list of filenames and you want the third one, or a list of prompts from a text reader and you're stepping through them one at a time. CGA_ExtractFromList is the grab-one-item node for exactly that situation.
It's deliberately generic. The input is a wildcard type (the pack's AlwaysEqualProxy("*")), which is a polite way of saying "anything goes" - images, strings, numbers, whatever a node emits as a list. You give it an index, it hands back the element at that index. That's the whole job, and it's the reason this node shows up in the pack's own batch workflow.
The inputs that matter
- input_data (
*) - the list (or batch, or tensor) you're indexing into. Any type. - value (INT, default 0, min 0) - the zero-based index of the item you want. 0 is the first item.
Output is a single * - the item at that position, whatever its type was.
The catch that will bite you
Out of range doesn't error - it returns None. That's the trap. If your list has 5 items and you ask for index 7, you get None flowing down your graph, and whatever node is downstream either crashes with a confusing "expected tensor, got None" or silently misbehaves. There's no clamp and no warning. If you're driving this from a loop counter, make sure your upper bound is the list length, not something you eyeballed.
Also note what "list" means here. For a Python list (like the ones CGA_TxtReaderNode produces) it's a clean index. Feed it a tensor and input_data[value] slices the first axis - same mental model, but you're getting a sub-tensor, not a "list item."
Where it shines
The pack's README pushes its text reader for batch file processing, and the bundled Batch translation of txt workflow shows the intended shape: CGA_TxtReaderNode dumps a folder of files into two lists, a loop counter steps, and two CGA_ExtractFromList nodes pull the matching filename and content out of each list by index. It's the unglamorous but essential piece that makes the loop actually loop.
Install
Part of ComfyUI_CGAnimittaTools. Manager: search the pack title, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/cganimitta/ComfyUI_CGAnimittaTools
The pack has no heavy dependencies - requirements.txt is torch, numpy, pathlib, all standard ComfyUI fare - and no models to download. You'll find this node under the CGAnimittaTools menu group after restart.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_data | * | — | |
| value | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |