ComfyUI Node

Pandas Save CSV

Pandas Save CSV

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas Save CSV
  • dataframe
  • STRING
file_path

ComfyUI doesn't make saving your data natural - the canvas is built to hand images onward, not write files to disk. Pandas Save CSV is the escape hatch: it takes a DataFrame, writes it to a CSV file at a path you give it, and shows you the table as text right on the node. Run your whole analysis as a graph, then dump the result so Excel (or a colleague, or a second workflow) can pick it up. It's one of the few nodes in this pack marked as an output node, and it's genuinely the "done" signal at the end of a pipeline.

It's part of HowToSD/ComfyUI-Data-Analysis. Under the hood it borrows the UI pattern from pythongosssss's show-text nodes - that's where the "display the result on the node itself" trick comes from - and the pack credits that source in its credit/ folder.

How it works

Straightforward: dataframe.to_csv(path_or_buf=file_path). The file_path field is a single-line STRING, and here's the important bit - paths are relative to your ComfyUI installation directory unless you use an absolute path. So output/results.csv writes into ComfyUI/output/results.csv, not wherever you happen to be looking. Absolute paths (C:/Users/you/data/results.csv or /home/you/data/results.csv) always work and are the less confusing option.

Because it's an output node, its STRING output is a list (the DataFrame rendered as text) that displays on the node itself and gets embedded back into the workflow. The node returns the text even when the write succeeds, so you can also wire it to a text display.

Inputs and output

  • dataframe - what to save.
  • file_path - destination path (relative to ComfyUI install dir, or absolute).

Output: a list of STRING - the DataFrame as text.

Installation

Standard for this pack. ComfyUI Manager: search Data analysis, install ComfyUI-Data-Analysis. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # example workflows need this name
pip install -r requirements.txt

Restart, reload. Deps: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml. No GPU, no models.

Gotchas

Two things bite people. First, if file_path is empty, the node just logs an error to the console and writes nothing - no crash, but also no file, so check the terminal if your CSV never appears. Second, the path-relative-to-ComfyUI quirk: results.csv lands in your ComfyUI root, and if that's not where you're looking you'll think it failed. When you do find your file, remember the CSV format defaults include the index - if your DataFrame has an index column you don't want in the file, set it aside first with the pack's Set Index node (set drop=True) before saving. For JSON output instead, the pack has the sibling Pandas Save JSON node.

CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
dataframeDATAFRAME
file_pathSTRING

Outputs (1)

NameTypeDescription
STRINGSTRING