From a9ffde3eb01d844cd2ffd2de4823bdab5fe31f77 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 12 Sep 2024 09:47:41 -0600 Subject: [PATCH] =?UTF-8?q?Validaci=C3=B3n=20de=20grupo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 688321b..b5ec444 100644 --- a/app.py +++ b/app.py @@ -155,13 +155,13 @@ def extract(driver, username: str, password: str): historial_html_io = StringIO(f"{historial_html}
") df = pd.read_html(historial_html_io)[0] - if 'GRUPO' not in df.columns: - raise KeyError("Column 'GRUPO' not found in the DataFrame") - - df['PERIODO'] = df['PERIODO'].apply(lambda x: str(x).replace('.0', '') if isinstance(x, (float, int)) else x) - - json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records') + json_result = [] + if 'GRUPO' in df.columns: + df['PERIODO'] = df['PERIODO'].apply(lambda x: str(x).replace('.0', '') if isinstance(x, (float, int)) else x) + json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records') + + query = insert_alumno_extraccion(datos_html, materias_html, username_integer, json_result) print("Data extracted successfully") return json_result