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
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user