Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,9 @@ import pandas as pd
|
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
import uuid
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def procesar_bases(file1, file2):
|
| 8 |
try:
|
|
@@ -122,19 +125,20 @@ def procesar_bases(file1, file2):
|
|
| 122 |
|
| 123 |
|
| 124 |
# --- Existing code ends here ---
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
|
| 130 |
-
dff_expanded_final.to_excel(
|
| 131 |
-
dfp_expanded_final.to_excel(
|
| 132 |
-
empty_concepto_2.to_excel(
|
| 133 |
|
| 134 |
-
|
|
|
|
| 135 |
|
| 136 |
except Exception as e:
|
| 137 |
-
error_file = "/
|
| 138 |
with open(error_file, "w") as f:
|
| 139 |
f.write("Error:\n" + str(e))
|
| 140 |
return error_file, None, None
|
|
|
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
import uuid
|
| 6 |
+
import shutil
|
| 7 |
+
|
| 8 |
+
os.makedirs("outputs", exist_ok=True) # Carpeta pública para los resultados
|
| 9 |
|
| 10 |
def procesar_bases(file1, file2):
|
| 11 |
try:
|
|
|
|
| 125 |
|
| 126 |
|
| 127 |
# --- Existing code ends here ---
|
| 128 |
+
uid = uuid.uuid4().hex
|
| 129 |
+
output1_path = f"outputs/facturas_limpias_{uid}.xlsx"
|
| 130 |
+
output2_path = f"outputs/partidas_limpias_{uid}.xlsx"
|
| 131 |
+
output3_path = f"outputs/partidas_manuales_{uid}.xlsx"
|
| 132 |
|
| 133 |
+
dff_expanded_final.to_excel(output1_path, index=False, engine='openpyxl')
|
| 134 |
+
dfp_expanded_final.to_excel(output2_path, index=False, engine='openpyxl')
|
| 135 |
+
empty_concepto_2.to_excel(output3_path, index=False, engine='openpyxl')
|
| 136 |
|
| 137 |
+
# Devolver rutas relativas (Gradio las convertirá en URLs públicas si usas static_dir="outputs")
|
| 138 |
+
return output1_path, output2_path, output3_path
|
| 139 |
|
| 140 |
except Exception as e:
|
| 141 |
+
error_file = f"outputs/error_{uuid.uuid4().hex}.txt"
|
| 142 |
with open(error_file, "w") as f:
|
| 143 |
f.write("Error:\n" + str(e))
|
| 144 |
return error_file, None, None
|