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