GaboDataScientist commited on
Commit
c1be086
·
verified ·
1 Parent(s): b0b6e94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -122,12 +122,10 @@ def procesar_bases(file1, file2):
122
 
123
 
124
  # --- Existing code ends here ---
125
- # Guardamos archivos en rutas persistentes
126
- os.makedirs("outputs", exist_ok=True) # Crear carpeta outputs si no existe
127
-
128
- output1 = f"outputs/facturas_limpias_{uuid.uuid4().hex}.xlsx"
129
- output2 = f"outputs/partidas_limpias_{uuid.uuid4().hex}.xlsx"
130
- output3 = f"outputs/partidas_manuales_{uuid.uuid4().hex}.xlsx"
131
 
132
  dff_expanded_final.to_excel(output1, index=False, engine='openpyxl')
133
  dfp_expanded_final.to_excel(output2, index=False, engine='openpyxl')
@@ -136,14 +134,17 @@ def procesar_bases(file1, file2):
136
  return output1, output2, output3
137
 
138
  except Exception as e:
139
- return f"❌ Error: {str(e)}", None, None
 
 
 
140
 
141
  # Interfaz Gradio
142
  gr.Interface(
143
  fn=procesar_bases,
144
  inputs=[
145
- gr.File(label="Sube en formato excel la base Facturas", type="filepath"),
146
- gr.File(label="Sube en formato excel la base Partidas", type="filepath")
147
  ],
148
  outputs=[
149
  gr.File(label="Base Facturas Limpias"),
@@ -151,5 +152,5 @@ gr.Interface(
151
  gr.File(label="Base Partidas Manuales")
152
  ],
153
  title="Limpieza de la base Facturas y Partidas",
154
- description="Instrucciones: Sube dos archivos de Excel. El primero debe ser la base de 'Facturas', el segundo la base de 'Partidas'. El sistema devuelve tres archivos procesados, la base de Facturas, Partidas, y una base con las Partidas que deben ser agregadas manualmente."
155
  ).launch()
 
122
 
123
 
124
  # --- Existing code ends here ---
125
+ # Guardamos archivos en carpeta temporal
126
+ output1 = f"/tmp/facturas_limpias_{uuid.uuid4().hex}.xlsx"
127
+ output2 = f"/tmp/partidas_limpias_{uuid.uuid4().hex}.xlsx"
128
+ output3 = f"/tmp/partidas_manuales_{uuid.uuid4().hex}.xlsx"
 
 
129
 
130
  dff_expanded_final.to_excel(output1, index=False, engine='openpyxl')
131
  dfp_expanded_final.to_excel(output2, index=False, engine='openpyxl')
 
134
  return output1, output2, output3
135
 
136
  except Exception as e:
137
+ error_file = "/tmp/error.txt"
138
+ with open(error_file, "w") as f:
139
+ f.write("Error:\n" + str(e))
140
+ return error_file, None, None
141
 
142
  # Interfaz Gradio
143
  gr.Interface(
144
  fn=procesar_bases,
145
  inputs=[
146
+ gr.File(label="Sube en formato Excel la base Facturas", type="filepath"),
147
+ gr.File(label="Sube en formato Excel la base Partidas", type="filepath")
148
  ],
149
  outputs=[
150
  gr.File(label="Base Facturas Limpias"),
 
152
  gr.File(label="Base Partidas Manuales")
153
  ],
154
  title="Limpieza de la base Facturas y Partidas",
155
+ description="Instrucciones: Sube dos archivos de Excel. El primero debe ser la base de 'Facturas', el segundo la base de 'Partidas'. El sistema devuelve tres archivos procesados."
156
  ).launch()