-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
22 lines (19 loc) · 697 Bytes
/
Copy pathutils.py
File metadata and controls
22 lines (19 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import csv
from tkinter import messagebox
from tkinter import filedialog
def export_to_csv(data, headers):
file_path = filedialog.asksaveasfilename(
defaultextension=".csv",
filetypes=[("CSV files", "*.csv")],
title="Save Statement As"
)
if not file_path:
return
try:
with open(file_path, mode='w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(headers)
writer.writerows(data)
messagebox.showinfo("Success", f"Statement downloaded successfully to:\n{file_path}")
except Exception as e:
messagebox.showerror("Error", f"Failed to export statement:\n{e}")