James McCool commited on
Commit
ffa4d02
·
1 Parent(s): 8a5c645

Enhance error handling in `load_file.py` for lineup processing

Browse files

- Added a check to ensure that the maximum number of players in any lineup is a positive integer, providing user feedback when no valid lineups are found in the uploaded file. This improves the robustness of the data loading process.

Files changed (1) hide show
  1. global_func/load_file.py +5 -1
global_func/load_file.py CHANGED
@@ -34,8 +34,12 @@ def load_file(upload):
34
 
35
  # Split into individual columns and remove position indicators
36
  # First, determine the maximum number of players in any lineup
37
- max_players = df['Lineup'].str.split(',').str.len().max()
38
 
 
 
 
 
39
  # Create columns for each player
40
  for i in range(max_players):
41
  df[i] = df['Lineup'].str.split(',').str[i].str.strip()
 
34
 
35
  # Split into individual columns and remove position indicators
36
  # First, determine the maximum number of players in any lineup
37
+ max_players = int(df['Lineup'].str.split(',').str.len().max())
38
 
39
+ if max_players <= 0:
40
+ st.error('No valid lineups found in the uploaded file')
41
+ return None
42
+
43
  # Create columns for each player
44
  for i in range(max_players):
45
  df[i] = df['Lineup'].str.split(',').str[i].str.strip()