The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Let the save text node save in csv format. (#15217)
comfyanonymouse0951a9c7e47
diff --git a/comfy_extras/nodes_text.py b/comfy_extras/nodes_text.pyindex a485f5df8..82efc247f 100644--- a/comfy_extras/nodes_text.py+++ b/comfy_extras/nodes_text.py@@ -8,6 +8,13 @@ import folder_pathsclass SaveTextNode(io.ComfyNode):"""Save text content to .txt, .md, or .json."""+ FORMAT_EXTENSIONS = {+ "txt": "txt",+ "csv": "csv",+ "md": "md",+ "json": "json",+ }+@classmethoddef define_schema(cls):return io.Schema(@@ -19,7 +26,7 @@ class SaveTextNode(io.ComfyNode):inputs=[io.String.Input("text", force_input=True),io.String.Input("filename_prefix", default="ComfyUI"),- io.Combo.Input("format", options=["txt", "md", "json"], default="txt"),+ io.Combo.Input("format", options=list(cls.FORMAT_EXTENSIONS), default="txt"),],outputs=[io.String.Output(display_name="text")],is_output_node=True,@@ -27,6 +34,10 @@ class SaveTextNode(io.ComfyNode):@classmethoddef execute(cls, text, filename_prefix, format):+ extension = cls.FORMAT_EXTENSIONS.get(format)+ if extension is None:+ raise ValueError(f"Unsupported text format: {format!r}")+full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix,folder_paths.get_output_directory(),@@ -34,10 +45,10 @@ class SaveTextNode(io.ComfyNode):1,)- file = f"{filename}_{counter:05}.{format}"+ file = f"{filename}_{counter:05}.{extension}"filepath = os.path.join(full_output_folder, file)- if format == "json":+ if extension == "json":# tries to pretty print otherwise saves normallytry:data = json.loads(text)