Nodes/ComfyUI-huggingface_dataset/πŸ€— Dataset Select Rows
ComfyUI Node

πŸ€— Dataset Select Rows

Pick exact rows by index β€” comma lists, Python slices, all of it

By StableLlamaΒ·Created a day agoΒ·Updated a day agoΒ· 1
πŸ€— Dataset Select Rows
  • dataset
  • dataset
β—„indices0:100β–Ί

Take gives you the first N rows. Skip drops the first N. But what if you want row 0, row 2, and row 4 - or every hundredth row, or a middle block? That's πŸ€— Dataset Select Rows. It's the precision tool of the pack: you type exactly which rows to keep, using comma-separated indices and/or Python-style slices, and it hands back a dataset with only those rows.

How it works

Under the hood it calls datasets.Dataset.select, which keeps rows by their position. What makes it usable as a node is the indices text field accepting both syntaxes at once:

  • Comma-separated indices - 0, 2, 4 keeps exactly those three rows.
  • Slices - 0:100 keeps rows 0–99; 0:100:2 keeps every second row in that range (the start:stop:step form Python users already know). An open slice like 50: runs to the last row.

You can mix them in one box (0:10, 20, 30:40) - handy for "these specific rows plus this whole block." The default is 0:100, which is also the best mental model: this is the node you use when you know positions, not content. If you want rows where a value matches, that's the Filter node's job; Select is for grabbing by index.

Inputs and output

Two inputs total: the dataset (a fully-loaded one - see below) and indices. One output: the reduced HUGGINGFACE_DATASET, ready to chain into anything else in the pack or materialize.

The loaded-only catch

Select is loaded-only, same as Sort and Flatten: select needs a materialized datasets.Dataset, so feeding it a streaming IterableDataset raises a clear error telling you to disable streaming on the loader. For streaming data, Take/Skip are the streaming-safe stand-ins - but they only do the front of the stream, which is precisely the gap Select fills.

Two small cautions, both about indices going stale. If you shuffle or filter after selecting, positions no longer mean what they did. And selecting by hard-coded indices into a dataset whose upstream order you changed is a quiet way to get wrong rows with no error - so put the Select late in the chain, right where row order is finalized.

Installing it

Same pack as the rest: StableLlama/ComfyUI-huggingface_dataset. ComfyUI-Manager β†’ search "Hugging Face dataset", or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-huggingface_dataset
pip install -r requirements.txt

Restart ComfyUI. Dependency is just datasets, installed for you by Manager.

CategoryHugging Face πŸ€—

Inputs (2)

NameTypeDefaultDescription
datasetHUGGINGFACE_DATASETFully-loaded dataset to select rows from (from the πŸ€— Dataset Loader or another dataset node).
indicesSTRING0:100Rows to keep: comma-separated indices (0, 2, 4) and/or Python slices (0:100, 0:100:2); an open slice runs to the last row.

Outputs (1)

NameTypeDescription
datasetHUGGINGFACE_DATASETThe dataset with only the selected rows.