Nodes/ComfyDL/Read Text → Dataset
ComfyUI Node

Read Text → Dataset

Tab-separated dumps, no header, and one default that will bite you

By Cynthia-lxx·Created 3 months ago·Updated 12 days ago· 7
Read Text → Dataset
    • dataset
    ◄filecdl_dataset.txt►
    ◄target►
    ◄delimiter ►
    ◄dtypefloat32►
    ◄headerfalse►

    The short version

    ComfyDL is Cynthia-lxx's pack for doing actual deep learning inside ComfyUI - the node library is derived from the d2l textbook codebase, so it's all from-scratch trainers and textbook primitives rather than diffusion plumbing. Its DATASET type is a bundle of a feature tensor, optional labels and column names that flows between the data nodes by reference.

    Read Text → Dataset gets plain .txt numbers into that type. It exists because the CSV reader assumes a header and the C engine; this one defaults to no header and always uses pandas' Python parsing engine, which means any single-character separator works, tabs included - and it's the one that shrugs at files which aren't really CSVs at all, just columns of numbers exported by some ancient tool, a log dumper, or np.savetxt.

    How it works

    Under the hood it's pd.read_csv(file, sep=delimiter, header=0 if header else None, engine="python"), then the same CdlDataset.from_dataframe path as every other reader: the target column (if you name one) is popped off as labels, the remaining columns are turned into a float32/float64 tensor via torch.from_numpy, and the column names travel with the dataset as feature_names.

    The Python engine is the interesting bit. It's slower than the C engine, but because it's always selected, a regex separator like \s+ parses cleanly. That's how you eat a log file where columns are separated by variable runs of spaces - the C engine would either guess wrong or refuse.

    Inputs and outputs

    Required: file (default cdl_dataset.txt) and target. Optional: delimiter (default \t - a tab), dtype (float32/float64) and header, which defaults to False here, unlike the CSV reader.

    Output is one dataset socket. Wire it to Dataset → Preview to check what pandas actually parsed - for text files, that's not paranoia, that's the workflow.

    Install

    Manager → search ComfyDL, or:

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

    then restart. The pack's own requirements are light (matplotlib, IPython, matplotlib-inline); the readers lean on pandas, which normally arrives with other node packs - pip install pandas if you get No module named 'pandas'. A missing dependency doesn't always announce itself loudly, because the pack imports each node module in a try/except and only prints [ComfyDL] Warning: Failed to load <module> to the console. If ComfyDL nodes are absent from the menu, read the console before you reinstall anything.

    The header default, and why it matters

    header = False is correct for a bare numbers dump - but it has a knock-on effect people miss. With no header row, pandas names the columns 0, 1, 2, … and target is matched by name. So on a headerless file you cannot point target at your label column: pass "" (empty) and you get an unlabelled dataset. That's fine for Dataset → Write CSV or a preview, and useless for training - Linear Regression Train needs labels.

    If your text file does have a header line, flip header to True and target works normally.

    Where people get burned

    Delimiter mismatch is silent. A space-separated file read with the default tab delimiter parses as one giant column of strings, which then fails the float conversion - or worse, parses as a single feature. Set delimiter to " " (or "\s+" for ragged spacing) and check with Preview.

    Everything non-numeric has to go. Like every reader in the pack, every non-target column becomes a float feature. A text column full of labels isn't ignored, it's a numpy conversion error.

    Paths are relative to ComfyUI's working directory, not wherever you think you are. Absolute paths, always.

    NaN survives. Blank fields come through as NaN and flow into the tensors, where they poison a training loss. There's no dropna anywhere in this chain.

    Big files are loaded whole. The node reads the file, builds a DataFrame, and holds the tensors in RAM for the rest of the run. There's no usecols or chunking knob - for a multi-gigabyte dump, preprocess outside ComfyUI and hand it a smaller file.

    Categoryd2l/Datasets

    Inputs (5)

    NameTypeDefaultDescription
    fileSTRINGcdl_dataset.txt—
    targetSTRING—
    delimiteroptSTRING —
    dtypeoptCOMBOfloat322 options: float32, float64
    headeroptBOOLEANfalse—

    Outputs (1)

    NameTypeDescription
    datasetDATASET—