Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -379,12 +379,24 @@ def _load_excel_as_text(file_name: str) -> str:
|
|
379 |
try:
|
380 |
xl = pd.ExcelFile(file_path)
|
381 |
sheets = xl.sheet_names
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
all_text = ""
|
383 |
for sheet in sheets:
|
384 |
df = xl.parse(sheet)
|
385 |
all_text += f"\nSheet: {sheet}\n"
|
386 |
all_text += df.to_string(index=False)
|
387 |
return all_text
|
|
|
388 |
except Exception as e:
|
389 |
print(f"[ERRORE] Impossibile leggere il file Excel: {e}")
|
390 |
return "ERROR: Could not read Excel file."
|
|
|
379 |
try:
|
380 |
xl = pd.ExcelFile(file_path)
|
381 |
sheets = xl.sheet_names
|
382 |
+
|
383 |
+
xl = xl.applymap(lambda x: f"{x:.2f}" if isinstance(x, float) else x)
|
384 |
+
|
385 |
+
# Esporta in formato CSV con separatore "pipe" per chiarezza (| colonna |)
|
386 |
+
csv_buffer = StringIO()
|
387 |
+
xl.to_csv(csv_buffer, index=False)
|
388 |
+
xl_string = csv_buffer.getvalue()
|
389 |
+
csv_buffer.close()
|
390 |
+
return xl_string
|
391 |
+
|
392 |
+
'''
|
393 |
all_text = ""
|
394 |
for sheet in sheets:
|
395 |
df = xl.parse(sheet)
|
396 |
all_text += f"\nSheet: {sheet}\n"
|
397 |
all_text += df.to_string(index=False)
|
398 |
return all_text
|
399 |
+
'''
|
400 |
except Exception as e:
|
401 |
print(f"[ERRORE] Impossibile leggere il file Excel: {e}")
|
402 |
return "ERROR: Could not read Excel file."
|