James McCool
Refactor file type checks in loading functions: update conditions in load_dk_fd_file.py, load_file.py, and load_ss_file.py to use substring checks for file extensions, improving readability and maintainability. Remove debug print statements from load_dk_fd_file.py and app.py to clean up the code.
dbc3f23
| import streamlit as st | |
| import numpy as np | |
| import pandas as pd | |
| import time | |
| from fuzzywuzzy import process | |
| def load_ss_file(lineups, csv_file): | |
| df = csv_file.copy() | |
| try: | |
| name_dict = dict(zip(df['ID'], df['Name'])) | |
| except: | |
| name_dict = dict(zip(df['Id'], df['Nickname'])) | |
| # Now load and process the lineups file | |
| try: | |
| if '.csv' in lineups.name: | |
| lineups_df = pd.read_csv(lineups) | |
| elif any(ext in lineups.name for ext in ['.xls', '.xlsx']): | |
| lineups_df = pd.read_excel(lineups) | |
| else: | |
| st.error('Please upload either a CSV or Excel file for lineups') | |
| return None, None | |
| export_df = lineups_df.copy() | |
| # Map the IDs to names | |
| for col in lineups_df.columns: | |
| lineups_df[col] = lineups_df[col].map(name_dict) | |
| return export_df, lineups_df | |
| except Exception as e: | |
| st.error(f'Error loading lineups file: {str(e)}') | |
| return None, None |