Spaces:
Sleeping
Sleeping
Create utils/excel_operations.py
Browse files- utils/excel_operations.py +13 -0
utils/excel_operations.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
|
3 |
+
def read_excel(file_path):
|
4 |
+
try:
|
5 |
+
return pd.read_excel(file_path).to_dict(orient="records")
|
6 |
+
except Exception:
|
7 |
+
return []
|
8 |
+
|
9 |
+
def write_excel(file_path, data):
|
10 |
+
try:
|
11 |
+
pd.DataFrame(data).to_excel(file_path, index=False)
|
12 |
+
except Exception as e:
|
13 |
+
print(f"Error writing to {file_path}: {e}")
|