Nodes/ComfyUI_Fill-Nodes/FL Caption To CSV
ComfyUI Node

FL Caption To CSV

Roll a folder of image + caption files into one CSV

By filliptm·Created 3 years ago·Updated about 9 hours ago· 628
FL Caption To CSV
    • CSV
    image_directory

    You've got a dataset folder - images plus their matching .txt caption files, the standard training layout. Now you want the whole thing as one table: filename in one column, caption in the next. Maybe to eyeball it, maybe to upload it, maybe to feed some other tool. FL_CaptionToCSV scans the folder and builds exactly that CSV for you, no spreadsheet gymnastics.

    It's a small bookkeeping node, but dataset work is full of moments where you want to see your captions all in one place rather than opening thirty text files. This collapses them into a single scannable artifact.

    How it works

    Point it at a directory and it walks the images, finds each one's corresponding caption text file, and assembles an in-memory CSV with two columns: image_file and caption. It returns that as CSV data (UTF-8 bytes) rather than writing to disk - which is the part that trips people up, so it's worth saying plainly up front. The output is a handoff to another node, not a saved file.

    The inputs and outputs that matter

    One input:

    • image_directory (STRING) - the path to your dataset folder. The images and their .txt captions should live here together, sharing base filenames.

    Output is a single CSV - a custom CSV data type. This is important: it's not a STRING and not a file path. It's meant to plug into a node that consumes the CSV type. In this pack that's FL_SaveCSV, which writes the bytes to an actual .csv on disk. So the normal pattern is FL_CaptionToCSV → FL_SaveCSV.

    It's an output node, so it runs even if you don't wire the CSV anywhere - but if you want the file, connect the save node.

    When you'd reach for it

    Right after you've captioned a dataset and want a manifest of it. Handy before a HuggingFace upload, for a quick sanity pass over caption quality, or as the input to any downstream step that prefers a table over loose files. It's the inverse companion to the pack's CSV-reading nodes, which go the other direction.

    Installing it

    ComfyUI ManagerComfyUI_Fill-Nodes → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/filliptm/ComfyUI_Fill-Nodes
    

    then restart. No special dependency for this node.

    Common issues & troubleshooting

    The CSV output "doesn't connect" to anything. Because it's the pack's CSV type, not a string. It only wires into nodes that accept that type - chiefly FL_SaveCSV. If you want the raw text, that's a different flow.

    Captions come out blank. The node pairs each image with a caption file of the matching name. If your captions are embedded in image metadata, or the .txt files are named differently from the images, there's nothing for it to read. Confirm you actually have img.png + img.txt pairs in the folder.

    Nothing written to disk. By design - this node builds the CSV in memory. Add FL_SaveCSV downstream and give it a path to persist it.

    Wrong or empty directory. A bad image_directory yields an empty CSV. Double-check the path is correct and points at the folder that actually holds the pairs.

    Category🏵️Fill Nodes/Captioning

    Inputs (1)

    NameTypeDefaultDescription
    image_directorySTRING

    Outputs (1)

    NameTypeDescription
    CSVCSV