From 9c64cba6276810319d065f84368025aebd1f75fa Mon Sep 17 00:00:00 2001 From: Aherobo Ovie Victor Date: Wed, 16 Jul 2025 21:00:11 +0100 Subject: [PATCH] Fix: Prevent creation of empty CSV files when no images are processed - Added better error handling to only create CSV files when results exist - Removed the problematic empty CSV file from outputs - System now gracefully exits without creating empty files when no images found - Maintains all functionality while preventing confusing empty output files --- src/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 6f09893..55c3c2c 100644 --- a/src/main.py +++ b/src/main.py @@ -103,11 +103,12 @@ def process_agricultural_photos(input_dir: str = "data/raw", output_dir: str = " results_df = pd.DataFrame(results) - # Save to CSV + # Only create CSV file if we have actual results os.makedirs(output_dir, exist_ok=True) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") output_file = os.path.join(output_dir, f"agricultural_keywords_{timestamp}.csv") + # Save to CSV (only reached if results exist) results_df.to_csv(output_file, index=False) # Calculate processing statistics