Forráskód Böngészése

Verificar grupo

Verificar campo de grupo ['GRUPO']
Alejandro Rosales 1 éve
szülő
commit
59b92549dc
1 módosított fájl, 3 hozzáadás és 0 törlés
  1. 3 0
      app.py

+ 3 - 0
app.py

@@ -109,6 +109,9 @@ def extract(username: str, password: str):
         historial_html_io = StringIO(f"<table>{historial_html}</table>")
         historial_html_io = StringIO(f"<table>{historial_html}</table>")
         # Read the HTML table into a DataFrame
         # Read the HTML table into a DataFrame
         df = pd.read_html(historial_html_io)[0]
         df = pd.read_html(historial_html_io)[0]
+        
+        if 'GRUPO' not in df.columns:
+           raise KeyError("Column 'GRUPO' not found in the DataFrame")
 
 
         # Convert the DataFrame to JSON
         # Convert the DataFrame to JSON
         json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records')
         json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records')