From 05e5cb34f3fa3be5592b8425cd7cae1573bcec38 Mon Sep 17 00:00:00 2001 From: CloneBro Date: Sat, 1 Aug 2026 07:02:13 +0000 Subject: [PATCH] Add export utilities (CSV, JSON) --- src/utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/utils.py diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..0ce1ae9 --- /dev/null +++ b/src/utils.py @@ -0,0 +1,20 @@ +""" +Utility functions for the project. +""" + +import csv +import json + +def export_to_csv(data, filename): + """Export list of dicts to CSV file.""" + if not data: + return + with open(filename, 'w', newline="") as f: + writer = csv.DictWriter(f, fieldnames=data[0].keys()) + writer.writeheader() + writer.writerows(data) + +def export_to_json(data, filename): + """Export data to JSON file.""" + with open(filename, 'w') as f: + json.dump(data, f, indent=2)