Update app.py
Browse files
app.py
CHANGED
@@ -461,7 +461,7 @@ def exportar_informe_latex(df_valid, informe_md):
|
|
461 |
f.write(informe_tex)
|
462 |
return filename
|
463 |
|
464 |
-
def exportar_word(df, informe_md, unidad_medida, filas_seleccionadas
|
465 |
df_valid = df.copy()
|
466 |
col_predicha_num = "Concentraci贸n Predicha Num茅rica"
|
467 |
col_real_promedio = f"Concentraci贸n Real Promedio ({unidad_medida})"
|
@@ -491,7 +491,7 @@ def exportar_word(df, informe_md, unidad_medida, filas_seleccionadas, columnas_a
|
|
491 |
|
492 |
return filename # Retornamos el nombre del archivo
|
493 |
|
494 |
-
def exportar_latex(df, informe_md, filas_seleccionadas
|
495 |
df_valid = df.copy()
|
496 |
col_predicha_num = "Concentraci贸n Predicha Num茅rica"
|
497 |
col_real_promedio = [col for col in df_valid.columns if 'Real Promedio' in col][0]
|
@@ -596,7 +596,7 @@ def cargar_excel(file):
|
|
596 |
|
597 |
# Verificar que el archivo tenga al menos dos pesta帽as
|
598 |
if len(df) < 2:
|
599 |
-
return "El archivo debe tener al menos dos pesta帽as.", None, None, None, None, None, None
|
600 |
|
601 |
# Obtener la primera pesta帽a como referencia
|
602 |
primera_pesta帽a = next(iter(df.values()))
|
@@ -608,18 +608,12 @@ def cargar_excel(file):
|
|
608 |
# Generar la tabla base
|
609 |
df_base = generar_tabla(n_filas, concentracion_inicial, unidad_medida, n_replicas)
|
610 |
|
611 |
-
# Detectar columnas de absorbancia
|
612 |
-
columnas_absorbancia = [col for col in primera_pesta帽a.columns if 'Absorbancia' in col]
|
613 |
-
|
614 |
-
if not columnas_absorbancia:
|
615 |
-
return "No se encontraron columnas de absorbancia en el archivo.", None, None, None, None, None, None, None
|
616 |
-
|
617 |
# Llenar la tabla con los datos de cada pesta帽a
|
618 |
for i, (sheet_name, sheet_df) in enumerate(df.items(), start=1):
|
619 |
col_real = f"Concentraci贸n Real {i} ({unidad_medida})"
|
620 |
df_base[col_real] = sheet_df.iloc[:, 1].values
|
621 |
|
622 |
-
return concentracion_inicial, unidad_medida, n_filas, n_replicas, df_base,
|
623 |
|
624 |
def calcular_regresion_tabla_principal(df, unidad_medida, filas_seleccionadas_regresion,
|
625 |
palette_puntos, estilo_puntos,
|
@@ -1077,7 +1071,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
|
|
1077 |
cargar_excel_btn.upload(
|
1078 |
fn=cargar_excel,
|
1079 |
inputs=[cargar_excel_btn],
|
1080 |
-
outputs=[concentracion_input, unidad_input, filas_slider, replicas_slider, tabla_output,
|
1081 |
)
|
1082 |
|
1083 |
# Evento al presionar el bot贸n Ajustar Decimales
|
@@ -1143,13 +1137,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
|
|
1143 |
# Eventos de exportar informes
|
1144 |
exportar_word_btn.click(
|
1145 |
fn=exportar_word,
|
1146 |
-
inputs=[tabla_output, informe_output, unidad_input, filas_seleccionadas
|
1147 |
outputs=exportar_word_file
|
1148 |
)
|
1149 |
|
1150 |
exportar_latex_btn.click(
|
1151 |
fn=exportar_latex,
|
1152 |
-
inputs=[tabla_output, informe_output, filas_seleccionadas
|
1153 |
outputs=exportar_latex_file
|
1154 |
)
|
1155 |
|
@@ -1198,4 +1192,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
|
|
1198 |
|
1199 |
# Lanzar la interfaz
|
1200 |
if __name__ == "__main__":
|
1201 |
-
interfaz.launch()
|
|
|
461 |
f.write(informe_tex)
|
462 |
return filename
|
463 |
|
464 |
+
def exportar_word(df, informe_md, unidad_medida, filas_seleccionadas):
|
465 |
df_valid = df.copy()
|
466 |
col_predicha_num = "Concentraci贸n Predicha Num茅rica"
|
467 |
col_real_promedio = f"Concentraci贸n Real Promedio ({unidad_medida})"
|
|
|
491 |
|
492 |
return filename # Retornamos el nombre del archivo
|
493 |
|
494 |
+
def exportar_latex(df, informe_md, filas_seleccionadas):
|
495 |
df_valid = df.copy()
|
496 |
col_predicha_num = "Concentraci贸n Predicha Num茅rica"
|
497 |
col_real_promedio = [col for col in df_valid.columns if 'Real Promedio' in col][0]
|
|
|
596 |
|
597 |
# Verificar que el archivo tenga al menos dos pesta帽as
|
598 |
if len(df) < 2:
|
599 |
+
return "El archivo debe tener al menos dos pesta帽as.", None, None, None, None, None, None
|
600 |
|
601 |
# Obtener la primera pesta帽a como referencia
|
602 |
primera_pesta帽a = next(iter(df.values()))
|
|
|
608 |
# Generar la tabla base
|
609 |
df_base = generar_tabla(n_filas, concentracion_inicial, unidad_medida, n_replicas)
|
610 |
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
# Llenar la tabla con los datos de cada pesta帽a
|
612 |
for i, (sheet_name, sheet_df) in enumerate(df.items(), start=1):
|
613 |
col_real = f"Concentraci贸n Real {i} ({unidad_medida})"
|
614 |
df_base[col_real] = sheet_df.iloc[:, 1].values
|
615 |
|
616 |
+
return concentracion_inicial, unidad_medida, n_filas, n_replicas, df_base, "", None, ""
|
617 |
|
618 |
def calcular_regresion_tabla_principal(df, unidad_medida, filas_seleccionadas_regresion,
|
619 |
palette_puntos, estilo_puntos,
|
|
|
1071 |
cargar_excel_btn.upload(
|
1072 |
fn=cargar_excel,
|
1073 |
inputs=[cargar_excel_btn],
|
1074 |
+
outputs=[concentracion_input, unidad_input, filas_slider, replicas_slider, tabla_output, estado_output, graficos_output, informe_output]
|
1075 |
)
|
1076 |
|
1077 |
# Evento al presionar el bot贸n Ajustar Decimales
|
|
|
1137 |
# Eventos de exportar informes
|
1138 |
exportar_word_btn.click(
|
1139 |
fn=exportar_word,
|
1140 |
+
inputs=[tabla_output, informe_output, unidad_input, filas_seleccionadas],
|
1141 |
outputs=exportar_word_file
|
1142 |
)
|
1143 |
|
1144 |
exportar_latex_btn.click(
|
1145 |
fn=exportar_latex,
|
1146 |
+
inputs=[tabla_output, informe_output, filas_seleccionadas],
|
1147 |
outputs=exportar_latex_file
|
1148 |
)
|
1149 |
|
|
|
1192 |
|
1193 |
# Lanzar la interfaz
|
1194 |
if __name__ == "__main__":
|
1195 |
+
interfaz.launch()
|