| # export_to_spreadsheet.py | |
| import csv | |
| import os | |
| def export_to_csv(data): | |
| if not data: | |
| print("No data to export. Skipping CSV creation.") | |
| return | |
| output_file = os.path.join(os.path.dirname(__file__), "digs_results.csv") | |
| try: | |
| with open(output_file, mode='w', newline='', encoding='utf-8') as csvfile: | |
| writer = csv.DictWriter(csvfile, fieldnames=data[0].keys()) | |
| writer.writeheader() | |
| writer.writerows(data) | |
| print(f"CSV export successful: {output_file}") | |
| except Exception as e: | |
| print(f"Error writing CSV: {e}") | |