Rhulli commited on
Commit
6771343
verified
1 Parent(s): 8497064

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -13
app.py CHANGED
@@ -203,20 +203,30 @@ with gr.Blocks() as demo:
203
  output_table = gr.Dataframe(headers=['Expresi贸n', 'Normalizaci贸n'], label="Resultados", type="pandas")
204
  output_logs = gr.Textbox(label="Logs", lines=5, interactive=False)
205
 
206
- csv_file_output = gr.File(label="Descargar resultados en CSV", visible=False)
207
-
208
- download_btn.click(fn=export_csv, inputs=[output_table], outputs=csv_file_output)
209
-
210
-
211
- run_btn.click(fn=run_pipeline, inputs=[files, raw_text, dct_input], outputs=[output_table, output_logs])
212
-
213
- def export_csv(df):
214
- csv_io = io.StringIO()
215
- df.to_csv(csv_io, index=False)
216
- csv_io.seek(0)
217
- return gr.File(file_obj=csv_io, visible=True)
218
 
219
- download_btn.click(fn=export_csv, inputs=[output_table], outputs=csv_file_output)
 
 
 
 
 
 
 
 
 
 
 
220
 
 
221
  demo.launch()
222
 
 
203
  output_table = gr.Dataframe(headers=['Expresi贸n', 'Normalizaci贸n'], label="Resultados", type="pandas")
204
  output_logs = gr.Textbox(label="Logs", lines=5, interactive=False)
205
 
206
+ # Despu茅s de definir output_table y output_logs:
207
+ download_btn = gr.Button("Descargar CSV")
208
+ csv_file_output = gr.File(label="Descargar resultados en CSV", visible=False)
209
+
210
+ # El click de procesar normales
211
+ run_btn.click(
212
+ fn=run_pipeline,
213
+ inputs=[files, raw_text, dct_input],
214
+ outputs=[output_table, output_logs]
215
+ )
 
 
216
 
217
+ # Funci贸n para exportar a CSV
218
+ def export_csv(df):
219
+ csv_path = "resultados.csv"
220
+ df.to_csv(csv_path, index=False)
221
+ return gr.update(value=csv_path, visible=True)
222
+
223
+ # Asociar el bot贸n de descarga al CSV
224
+ download_btn.click(
225
+ fn=export_csv,
226
+ inputs=[output_table],
227
+ outputs=[csv_file_output]
228
+ )
229
 
230
+ # Lanzar la app
231
  demo.launch()
232