Update ui/ui_core.py
Browse files- ui/ui_core.py +3 -4
ui/ui_core.py
CHANGED
@@ -12,16 +12,15 @@ from txagent.txagent import TxAgent
|
|
12 |
def extract_all_text_from_csv_or_excel(file_path, progress=None, index=0, total=1):
|
13 |
try:
|
14 |
if file_path.endswith(".csv"):
|
15 |
-
df = pd.read_csv(file_path, low_memory=False)
|
16 |
elif file_path.endswith((".xls", ".xlsx")):
|
17 |
-
df = pd.read_excel(file_path)
|
18 |
else:
|
19 |
return f"Unsupported spreadsheet format: {file_path}"
|
20 |
|
21 |
if progress:
|
22 |
progress((index + 1) / total, desc=f"Processed table: {os.path.basename(file_path)}")
|
23 |
|
24 |
-
# Group by "Booking Number" or "Form Name" if available
|
25 |
if "Booking Number" in df.columns:
|
26 |
groups = df.groupby("Booking Number")
|
27 |
elif "Form Name" in df.columns:
|
@@ -128,4 +127,4 @@ def create_ui(agent: TxAgent):
|
|
128 |
["Is there anything abnormal in the attached blood work report?"]
|
129 |
], inputs=message_input)
|
130 |
|
131 |
-
return demo
|
|
|
12 |
def extract_all_text_from_csv_or_excel(file_path, progress=None, index=0, total=1):
|
13 |
try:
|
14 |
if file_path.endswith(".csv"):
|
15 |
+
df = pd.read_csv(file_path, encoding="utf-8", errors="replace", low_memory=False)
|
16 |
elif file_path.endswith((".xls", ".xlsx")):
|
17 |
+
df = pd.read_excel(file_path, engine="openpyxl")
|
18 |
else:
|
19 |
return f"Unsupported spreadsheet format: {file_path}"
|
20 |
|
21 |
if progress:
|
22 |
progress((index + 1) / total, desc=f"Processed table: {os.path.basename(file_path)}")
|
23 |
|
|
|
24 |
if "Booking Number" in df.columns:
|
25 |
groups = df.groupby("Booking Number")
|
26 |
elif "Form Name" in df.columns:
|
|
|
127 |
["Is there anything abnormal in the attached blood work report?"]
|
128 |
], inputs=message_input)
|
129 |
|
130 |
+
return demo
|