Update ui/ui_core.py
Browse files- ui/ui_core.py +9 -8
ui/ui_core.py
CHANGED
@@ -20,13 +20,12 @@ def clean_final_response(text: str) -> str:
|
|
20 |
if len(responses) <= 1:
|
21 |
return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
|
22 |
|
23 |
-
# Support multiple [Final Analysis] sections
|
24 |
panels = []
|
25 |
for i, section in enumerate(responses[1:], 1):
|
26 |
final = section.strip()
|
27 |
panels.append(
|
28 |
-
f"<details style='background:#
|
29 |
-
f"<summary style='font-size:1.1em;font-weight:bold;padding:0.75em;background:#
|
30 |
f"<div style='padding:1em;line-height:1.6;'>{final.replace(chr(10), '<br>')}</div>"
|
31 |
f"</details>"
|
32 |
)
|
@@ -40,21 +39,23 @@ def extract_all_text_from_csv_or_excel(file_path: str, progress=None, index=0, t
|
|
40 |
if progress:
|
41 |
progress((index + 1) / total, desc=f"Reading spreadsheet: {os.path.basename(file_path)}")
|
42 |
|
|
|
43 |
if file_path.endswith(".csv"):
|
44 |
-
df = pd.read_csv(file_path,
|
45 |
elif file_path.endswith((".xls", ".xlsx")):
|
46 |
-
|
47 |
-
df = pd.read_excel(file_path, engine="openpyxl")
|
48 |
-
except:
|
49 |
-
df = pd.read_excel(file_path, engine="xlrd")
|
50 |
else:
|
51 |
return f"Unsupported spreadsheet format: {file_path}"
|
52 |
|
|
|
|
|
|
|
53 |
lines = []
|
54 |
for _, row in df.iterrows():
|
55 |
line = " | ".join(str(cell) for cell in row if pd.notna(cell))
|
56 |
if line:
|
57 |
lines.append(line)
|
|
|
58 |
return f"\U0001F4C4 {os.path.basename(file_path)}\n\n" + "\n".join(lines)
|
59 |
|
60 |
except Exception as e:
|
|
|
20 |
if len(responses) <= 1:
|
21 |
return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
|
22 |
|
|
|
23 |
panels = []
|
24 |
for i, section in enumerate(responses[1:], 1):
|
25 |
final = section.strip()
|
26 |
panels.append(
|
27 |
+
f"<details style='background:#1F2633;color:#fff;border-radius:12px;margin-bottom:1em;border:1px solid #37B6E9;'>"
|
28 |
+
f"<summary style='font-size:1.1em;font-weight:bold;padding:0.75em;background:#37B6E9;color:#fff;border-radius:12px 12px 0 0;'>🧠 Final Analysis #{i}</summary>"
|
29 |
f"<div style='padding:1em;line-height:1.6;'>{final.replace(chr(10), '<br>')}</div>"
|
30 |
f"</details>"
|
31 |
)
|
|
|
39 |
if progress:
|
40 |
progress((index + 1) / total, desc=f"Reading spreadsheet: {os.path.basename(file_path)}")
|
41 |
|
42 |
+
df = None
|
43 |
if file_path.endswith(".csv"):
|
44 |
+
df = pd.read_csv(file_path, encoding_errors="replace")
|
45 |
elif file_path.endswith((".xls", ".xlsx")):
|
46 |
+
df = pd.read_excel(file_path, engine=None)
|
|
|
|
|
|
|
47 |
else:
|
48 |
return f"Unsupported spreadsheet format: {file_path}"
|
49 |
|
50 |
+
if df is None or df.empty:
|
51 |
+
return f"⚠️ No data found in: {os.path.basename(file_path)}"
|
52 |
+
|
53 |
lines = []
|
54 |
for _, row in df.iterrows():
|
55 |
line = " | ".join(str(cell) for cell in row if pd.notna(cell))
|
56 |
if line:
|
57 |
lines.append(line)
|
58 |
+
|
59 |
return f"\U0001F4C4 {os.path.basename(file_path)}\n\n" + "\n".join(lines)
|
60 |
|
61 |
except Exception as e:
|