LATE.IO2 / backend /digs_engine /export_to_spreadsheet.py
AIEONE
Initial commit syncing local server with Hugging Face Space
490ec84
# 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}")