Nodes/ComfyDL/Read XLSX → Dataset
ComfyUI Node

Read XLSX → Dataset

The sheet field is a name, not an index — and that catches everyone

By Cynthia-lxx·Created 3 months ago·Updated 12 days ago· 7
Read XLSX → Dataset
    • dataset
    ◄filecdl_dataset.xlsx►
    ◄target►
    ◄sheet0►
    ◄dtypefloat32►

    What it is

    ComfyDL is Cynthia-lxx's d2l-derived pack for doing deep learning as ComfyUI graphs - the node set is textbook material (linear regression, squared loss, SGD, CNNs, attention) dragged onto a canvas. It uses one universal DATASET type: features, optional labels, column names, passed by reference between nodes. Read XLSX → Dataset is the reader for people whose numbers live in a spreadsheet, which - let's be honest - is most people with small data.

    It's the right node when your source is a workbook somebody hands you and you want to train on it without exporting by hand each time. Point it at the file, name the target column, done.

    How it works

    pd.read_excel(file, sheet_name=...) into a DataFrame, then the same CdlDataset.from_dataframe conversion every reader in the pack uses: the target column is stripped off into a labels tensor, the remaining columns are cast to float32 or float64 via torch.from_numpy, and the column names become feature_names.

    Excel is a format, not a plain grid - there are dtypes, merged cells, formulas, dates. Pandas reads the computed values, so formulas are fine (what Excel last saved is what you get). Dates come through as datetime columns, which is a problem; more on that below.

    Inputs and outputs

    Required: file (default cdl_dataset.xlsx) and target (label column name; empty means unlabelled). Optional: sheet (a STRING, default "0") and dtype.

    Output is one dataset. Typical wiring: Preview to check it parsed, then Dataset → Tensors, then Linear Regression Train, or a writer to convert the workbook to CSV/DB once.

    The sheet field is the trap. It's a string, and the code treats "" or "0" as "first sheet" and anything else as a sheet name. So typing 2 does not mean the third sheet - it means the sheet literally named 2. If your workbook's tabs are named things like q1_data, type that. If they aren't named anything useful, rename them or export the sheet you want to CSV.

    Install

    Manager → search ComfyDL, or:

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

    Restart. Now the dependency that matters for this node: reading .xlsx needs openpyxl, which is not in the pack's requirements (matplotlib, IPython, matplotlib-inline - that's the whole list). Pandas will tell you so with its own "Missing optional dependency 'openpyxl'" error, which is at least readable. Fix:

    pip install openpyxl
    

    Legacy .xls workbooks are a different engine again - pandas wants xlrd for those, and it isn't installed for you either.

    Where people get burned

    Dates and mixed columns. A date column becomes datetime64, and every non-target column is converted straight to float. That raises a numpy conversion error. Excel is also famous for making one column hold numbers, text and blanks because someone typed an "N/A" - same outcome.

    A spreadsheet is not a table. Title rows, notes in row 1, a totals row at the bottom, two tables side by side: pandas reads the grid as given, so you get columns named Unnamed: 0 and a row of totals as data. Put the header in row 1 and nothing else in the sheet before you point the node at it.

    Blank cells are NaN, nothing drops them, and NaNs propagate into the training loss. Clean in Excel.

    Relative file paths resolve against ComfyUI's working directory. Absolute paths, every time.

    Huge workbooks. Excel caps at ~1.05 million rows and pandas holds the whole sheet as a DataFrame plus a tensor. If you're near that scale, this is the wrong reader - go CSV.

    If ComfyDL nodes are missing from the menu entirely, read the console: the pack imports each node module inside a try/except and prints [ComfyDL] Warning: Failed to load <module>, so dependency problems show up as silence, not a dialog.

    Categoryd2l/Datasets

    Inputs (4)

    NameTypeDefaultDescription
    fileSTRINGcdl_dataset.xlsx—
    targetSTRING—
    sheetoptSTRING0—
    dtypeoptCOMBOfloat322 options: float32, float64

    Outputs (1)

    NameTypeDescription
    datasetDATASET—