Nodes/ComfyDL/Read String → Dataset
ComfyUI Node

Read String → Dataset

Paste a handful of numbers and prove the trainer works in 30 seconds

By Cynthia-lxx·Created 3 months ago·Updated 12 days ago· 7
Read String → Dataset
    • dataset
    ◄texta b c y 0 0 0 0.0 1 2 3 0.5 2 4 6 1.0 ►
    ◄target►
    ◄delimiter ►
    ◄dtypefloat32►
    ◄headertrue►

    What it's for

    Nobody reaches for a file reader to test a training graph. You reach for Read String → Dataset, type or paste a few rows of tab-separated numbers directly into the node, and you have a DATASET with no filesystem involved. ComfyDL is Cynthia-lxx's d2l-derived pack for running textbook deep learning inside ComfyUI, and this is its scratchpad node.

    It earns its place for three jobs: sanity-checking the whole data→train→plot chain before you point it at real data, demoing what a node does without shipping a file, and reproducing a textbook example exactly as the book writes it.

    The default sample is not random

    Open the node and the text box already contains this:

    a	b	c	y
    0	0	0	0.0
    1	2	3	0.5
    2	4	6	1.0
    

    That's the toy linear-regression set from the d2l book - three x-values, a target y, tabs between columns, header on the first line. Set target to y, wire dataset into Linear Regression Train, and you can watch weights and bias come out of a graph you built in under a minute. It's the fastest way to confirm the pack's training side is healthy on your machine before you blame your data.

    How it works

    The node wraps your pasted text in io.StringIO and hands it to pd.read_csv with engine="python" forced, using delimiter (default tab), header (default True), and then the standard CdlDataset.from_dataframe path: the target column is stripped off as labels, the rest becomes a float tensor, and the column names ride along as feature_names.

    Because the Python engine is always used, any single-character separator works - tabs, commas, semicolons - and a regex separator like \s+ parses too, if you pasted space-padded columns.

    Inputs and outputs

    Required: text (multiline) and target. Optional: delimiter (default \t), dtype (float32/float64) and header (default True - the pack's reader nodes disagree with each other here, which is deliberate: pasted data from the book has headers, bare number dumps usually don't).

    Output: a single dataset.

    Install

    Manager → search ComfyDL, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Cynthia-lxx/ComfyDL
    pip install -r ./ComfyDL/requirements.txt
    

    and restart. Requirements are just matplotlib/IPython/matplotlib-inline; pandas comes from your environment (every reader here needs it). If the nodes never appear in the menu, check the console for [ComfyDL] Warning: Failed to load <module> - the pack swallows per-module import errors, so a missing dependency can look like "the node doesn't exist."

    Where people get burned

    Whitespace you can't see. The parser is delimiter-sensitive and tabs are invisible. Paste a table that used spaces into a node set to tab and you get one column of text, then a numpy conversion error. When in doubt, set delimiter to \s+ and let the regex eat whatever alignment you copied.

    header = True means the first line becomes column names. Paste numbers with no header and the first data row silently becomes your feature names - and your target string won't match anything, raising target column not found.

    A column full of text kills it. Every non-target column is cast to float. Paste a row of labels or IDs and the conversion fails.

    Multi-row is fine, multi-block isn't. This is a rectangular table parser. Two blocks of data separated by a blank line and a title row won't be interpreted as two tables; the row becomes garbage columns.

    It's for small data. The whole thing is a long-running node holding a tensor in RAM, and there's no streaming. A few hundred rows, absolutely. A few hundred thousand - use the CSV or DB readers and keep this one for tests.

    Categoryd2l/Datasets

    Inputs (5)

    NameTypeDefaultDescription
    textSTRINGa b c y 0 0 0 0.0 1 2 3 0.5 2 4 6 1.0 —
    targetSTRING—
    delimiteroptSTRING —
    dtypeoptCOMBOfloat322 options: float32, float64
    headeroptBOOLEANtrue—

    Outputs (1)

    NameTypeDescription
    datasetDATASET—