Remove xlwings for hugging face
Browse files- apps/dump_compare.py +25 -21
- requirements.txt +0 -0
apps/dump_compare.py
CHANGED
@@ -4,8 +4,8 @@ import tempfile
|
|
4 |
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
-
|
8 |
-
|
9 |
|
10 |
# === Core Logic ===
|
11 |
|
@@ -18,29 +18,33 @@ def find_header_row(df, keyword="Dist_Name"):
|
|
18 |
raise ValueError(f"No row with '{keyword}' found.")
|
19 |
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
|
30 |
def read_sheet_fallback(file, sheet):
|
31 |
try:
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
raise RuntimeError(f"xlwings failed: {e2}")
|
44 |
|
45 |
|
46 |
def load_clean_df(file, sheet):
|
|
|
4 |
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
+
|
8 |
+
# import xlwings as xw
|
9 |
|
10 |
# === Core Logic ===
|
11 |
|
|
|
18 |
raise ValueError(f"No row with '{keyword}' found.")
|
19 |
|
20 |
|
21 |
+
# import xlwings as xw
|
22 |
+
# def read_sheet_fallback(file, sheet):
|
23 |
+
# try:
|
24 |
+
# app = xw.App(visible=False)
|
25 |
+
# book = app.books.open(file)
|
26 |
+
# sht = book.sheets[sheet]
|
27 |
+
# df = sht.used_range.options(pd.DataFrame, header=False, index=False).value
|
28 |
+
# book.close()
|
29 |
+
# app.quit()
|
30 |
+
# return df
|
31 |
+
# except Exception as e2:
|
32 |
+
# raise RuntimeError(f"xlwings failed: {e2}")
|
33 |
|
34 |
|
35 |
def read_sheet_fallback(file, sheet):
|
36 |
try:
|
37 |
+
# pandas can directly read Excel files
|
38 |
+
# sheet_name can be the sheet name (string) or sheet number (0-indexed)
|
39 |
+
df = pd.read_excel(file, sheet_name=sheet, header=None, engine="calamine")
|
40 |
+
return df
|
41 |
+
except FileNotFoundError:
|
42 |
+
raise FileNotFoundError(f"The file '{file}' was not found.")
|
43 |
+
except ValueError as e:
|
44 |
+
# This could happen if the sheet doesn't exist, or other pandas-related errors
|
45 |
+
raise ValueError(f"Error reading sheet '{sheet}' from '{file}': {e}")
|
46 |
+
except Exception as e:
|
47 |
+
raise RuntimeError(f"An unexpected error occurred: {e}")
|
|
|
48 |
|
49 |
|
50 |
def load_clean_df(file, sheet):
|
requirements.txt
CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
|
|