π€ Dataset Select Rows
Pick exact rows by index β comma lists, Python slices, all of it
- dataset
- dataset
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, 4keeps exactly those three rows. - Slices -
0:100keeps rows 0β99;0:100:2keeps every second row in that range (thestart:stop:stepform Python users already know). An open slice like50: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.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | HUGGINGFACE_DATASET | Fully-loaded dataset to select rows from (from the π€ Dataset Loader or another dataset node). | |
| indices | STRING | 0:100 | Rows 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)
| Name | Type | Description |
|---|---|---|
| dataset | HUGGINGFACE_DATASET | The dataset with only the selected rows. |