File size: 1,015 Bytes
d04558f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 lineups.name.endswith('.csv'):
            lineups_df = pd.read_csv(lineups)
        elif lineups.name.endswith(('.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