File size: 1,249 Bytes
c225a63 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import os
import comfy.utils
class FL_SaveCSV:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"csv_data": ("CSV",),
"output_directory": ("STRING", {"default": ""}),
"filename": ("STRING", {"default": "captions.csv"}),
},
}
RETURN_TYPES = ()
FUNCTION = "save_csv"
CATEGORY = "🏵️Fill Nodes/Captioning"
OUTPUT_NODE = True
def save_csv(self, csv_data, output_directory, filename):
# Ensure the output directory exists
os.makedirs(output_directory, exist_ok=True)
# Construct the full file path
file_path = os.path.join(output_directory, filename)
# Ensure the filename ends with .csv
if not file_path.lower().endswith('.csv'):
file_path += '.csv'
# Write the CSV data to the file
try:
with open(file_path, 'wb') as f:
f.write(csv_data)
print(f"CSV file saved successfully: {file_path}")
except Exception as e:
print(f"Error saving CSV file: {str(e)}")
return ()
@classmethod
def IS_CHANGED(cls, csv_data, output_directory, filename):
return float("NaN") |