James McCool
commited on
Commit
·
c0713d8
1
Parent(s):
a266f29
Enhance debugging output in load_contest_file function for lineup processing
Browse files- Added detailed print statements to track the processing of lineups and individual player items, improving traceability during execution.
- Updated the final output to display cleaned player lists, enhancing visibility into the data transformation process.
- These changes contribute to ongoing efforts to refine data handling and improve user experience within the application.
global_func/load_contest_file.py
CHANGED
|
@@ -84,16 +84,24 @@ def load_contest_file(upload, sport):
|
|
| 84 |
|
| 85 |
# Process each lineup
|
| 86 |
for idx, row in df.iterrows():
|
|
|
|
|
|
|
|
|
|
| 87 |
# Get all players in the lineup and clean up the strings
|
| 88 |
players = row['Lineup'].split(',')
|
|
|
|
|
|
|
| 89 |
cleaned_players = []
|
| 90 |
current_position = None
|
| 91 |
|
| 92 |
for item in players:
|
| 93 |
item = item.strip()
|
|
|
|
|
|
|
| 94 |
# If the item is just a position indicator, store it
|
| 95 |
if item in pos_values:
|
| 96 |
current_position = item
|
|
|
|
| 97 |
continue
|
| 98 |
|
| 99 |
# If we have a position and a player name
|
|
@@ -102,6 +110,7 @@ def load_contest_file(upload, sport):
|
|
| 102 |
for pos in pos_values:
|
| 103 |
if item.endswith(pos):
|
| 104 |
item = item[:-len(pos)].strip()
|
|
|
|
| 105 |
cleaned_players.append(item)
|
| 106 |
current_position = None
|
| 107 |
else:
|
|
@@ -110,11 +119,10 @@ def load_contest_file(upload, sport):
|
|
| 110 |
if item.endswith(pos):
|
| 111 |
item = item[:-len(pos)].strip()
|
| 112 |
break
|
|
|
|
| 113 |
cleaned_players.append(item)
|
| 114 |
|
| 115 |
-
print(f"\
|
| 116 |
-
print(f"Original lineup: {row['Lineup']}")
|
| 117 |
-
print(f"Cleaned players: {cleaned_players}")
|
| 118 |
|
| 119 |
# First pass: fill required positions (excluding OF)
|
| 120 |
required_positions = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS']
|
|
|
|
| 84 |
|
| 85 |
# Process each lineup
|
| 86 |
for idx, row in df.iterrows():
|
| 87 |
+
print(f"\nProcessing lineup {idx}:")
|
| 88 |
+
print(f"Original lineup string: {row['Lineup']}")
|
| 89 |
+
|
| 90 |
# Get all players in the lineup and clean up the strings
|
| 91 |
players = row['Lineup'].split(',')
|
| 92 |
+
print(f"After initial split: {players}")
|
| 93 |
+
|
| 94 |
cleaned_players = []
|
| 95 |
current_position = None
|
| 96 |
|
| 97 |
for item in players:
|
| 98 |
item = item.strip()
|
| 99 |
+
print(f"\nProcessing item: {item}")
|
| 100 |
+
|
| 101 |
# If the item is just a position indicator, store it
|
| 102 |
if item in pos_values:
|
| 103 |
current_position = item
|
| 104 |
+
print(f"Found position: {current_position}")
|
| 105 |
continue
|
| 106 |
|
| 107 |
# If we have a position and a player name
|
|
|
|
| 110 |
for pos in pos_values:
|
| 111 |
if item.endswith(pos):
|
| 112 |
item = item[:-len(pos)].strip()
|
| 113 |
+
print(f"Adding player with position {current_position}: {item}")
|
| 114 |
cleaned_players.append(item)
|
| 115 |
current_position = None
|
| 116 |
else:
|
|
|
|
| 119 |
if item.endswith(pos):
|
| 120 |
item = item[:-len(pos)].strip()
|
| 121 |
break
|
| 122 |
+
print(f"Adding player without position: {item}")
|
| 123 |
cleaned_players.append(item)
|
| 124 |
|
| 125 |
+
print(f"\nFinal cleaned players: {cleaned_players}")
|
|
|
|
|
|
|
| 126 |
|
| 127 |
# First pass: fill required positions (excluding OF)
|
| 128 |
required_positions = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS']
|