James McCool commited on
Commit
6c65277
·
1 Parent(s): ce6c2b2

Add detailed debug output for name matching process in app.py: include additional print statements to provide insights into the name-to-ID mapping, number of names to match, and results of the matching process, enhancing visibility for debugging and user feedback.

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -151,15 +151,24 @@ with tab1:
151
  st.session_state['csv_file']['Name'],
152
  st.session_state['csv_file']['Name + ID']
153
  ))
 
154
  except:
155
  name_id_map = dict(zip(
156
  st.session_state['csv_file']['Nickname'],
157
  st.session_state['csv_file']['Id']
158
  ))
 
 
 
 
159
 
160
  # Get all names at once
161
  names = projections['player_names'].tolist()
162
  choices = list(name_id_map.keys())
 
 
 
 
163
 
164
  # Process all names in one batch
165
  matches = process.extract(
@@ -169,6 +178,9 @@ with tab1:
169
  score_cutoff=85,
170
  limit=1 # Only get the best match
171
  )
 
 
 
172
 
173
  # Convert matches to dictionary - Fixed the match handling
174
  match_dict = {}
@@ -177,10 +189,15 @@ with tab1:
177
  match_dict[name] = name_id_map[match_list[0][0]] # Use the matched name to get the ID
178
  else:
179
  match_dict[name] = name # Keep original name if no good match
 
 
 
180
 
181
  # Apply the matches
182
  projections['upload_match'] = projections['player_names'].map(match_dict)
183
  st.session_state['export_dict'] = match_dict # Use match_dict directly
 
 
184
  st.write(st.session_state['export_dict'])
185
 
186
  st.session_state['origin_portfolio'] = st.session_state['portfolio'].copy()
 
151
  st.session_state['csv_file']['Name'],
152
  st.session_state['csv_file']['Name + ID']
153
  ))
154
+ print("Using Name + ID mapping")
155
  except:
156
  name_id_map = dict(zip(
157
  st.session_state['csv_file']['Nickname'],
158
  st.session_state['csv_file']['Id']
159
  ))
160
+ print("Using Nickname + Id mapping")
161
+
162
+ print(f"Number of names in name_id_map: {len(name_id_map)}")
163
+ print("Sample of name_id_map:", list(name_id_map.items())[:3])
164
 
165
  # Get all names at once
166
  names = projections['player_names'].tolist()
167
  choices = list(name_id_map.keys())
168
+
169
+ print(f"Number of names to match: {len(names)}")
170
+ print("Sample of names to match:", names[:3])
171
+ print("Sample of choices:", choices[:3])
172
 
173
  # Process all names in one batch
174
  matches = process.extract(
 
178
  score_cutoff=85,
179
  limit=1 # Only get the best match
180
  )
181
+
182
+ print(f"Number of matches found: {len(matches)}")
183
+ print("Sample of matches:", matches[:3])
184
 
185
  # Convert matches to dictionary - Fixed the match handling
186
  match_dict = {}
 
189
  match_dict[name] = name_id_map[match_list[0][0]] # Use the matched name to get the ID
190
  else:
191
  match_dict[name] = name # Keep original name if no good match
192
+
193
+ print(f"Number of entries in match_dict: {len(match_dict)}")
194
+ print("Sample of match_dict:", list(match_dict.items())[:3])
195
 
196
  # Apply the matches
197
  projections['upload_match'] = projections['player_names'].map(match_dict)
198
  st.session_state['export_dict'] = match_dict # Use match_dict directly
199
+
200
+ st.write("Export Dictionary Contents:")
201
  st.write(st.session_state['export_dict'])
202
 
203
  st.session_state['origin_portfolio'] = st.session_state['portfolio'].copy()