Download comfyui_fill-nodes/nodes/captioning/FL_LoadCSV.py from MarkLilly/mis-custom-nodes: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/comfyui_fill-nodes/nodes/captioning/FL_LoadCSV.py
- Command line
-
hf download hf://MarkLilly/mis-custom-nodes/comfyui_fill-nodes/nodes/captioning/FL_LoadCSV.py
-
curl -L -o FL_LoadCSV.py https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/comfyui_fill-nodes/nodes/captioning/FL_LoadCSV.py
1.58 kB
| import os | |
| import csv | |
| import io | |
| class FL_LoadCSV: | |
| def INPUT_TYPES(cls): | |
| return { | |
| "required": { | |
| "csv_path": ("STRING", {"default": ""}), | |
| }, | |
| } | |
| RETURN_TYPES = ("CSV", "INT") | |
| RETURN_NAMES = ("csv_data", "row_count") | |
| FUNCTION = "load_csv" | |
| CATEGORY = "🏵️Fill Nodes/Captioning" | |
| def load_csv(self, csv_path): | |
| if not csv_path: | |
| raise ValueError("CSV file path is not provided.") | |
| if not os.path.exists(csv_path): | |
| raise ValueError(f"CSV file does not exist: {csv_path}") | |
| if not csv_path.lower().endswith('.csv'): | |
| raise ValueError("File must have .csv extension") | |
| try: | |
| # Read the CSV file as binary data to match the expected CSV type | |
| with open(csv_path, 'rb') as f: | |
| csv_data = f.read() | |
| # Also read as text to count rows for the row_count output | |
| with open(csv_path, 'r', encoding='utf-8', newline='') as f: | |
| reader = csv.reader(f) | |
| row_count = sum(1 for row in reader) | |
| print(f"CSV file loaded successfully: {csv_path} ({row_count} rows)") | |
| except Exception as e: | |
| print(f"Error loading CSV file: {str(e)}") | |
| raise ValueError(f"Failed to load CSV file: {str(e)}") | |
| return (csv_data, row_count) | |
| def IS_CHANGED(cls, csv_path): | |
| if not csv_path or not os.path.exists(csv_path): | |
| return float("NaN") | |
| return os.path.getmtime(csv_path) |