File size: 975 Bytes
d04558f 9c7e08b d04558f 9c7e08b d04558f 9c7e08b 1689df1 9c7e08b 1689df1 9c7e08b 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 |
import streamlit as st
import numpy as np
import pandas as pd
import time
from fuzzywuzzy import process
## import global functions
from global_func.clean_player_name import clean_player_name
def load_file(upload):
if upload is not None:
try:
if upload.name.endswith('.csv'):
df = pd.read_csv(upload)
elif upload.name.endswith(('.xls', '.xlsx')):
df = pd.read_excel(upload)
else:
st.error('Please upload either a CSV or Excel file')
return None
export_df = df.copy()
for col in df.columns:
if df[col].dtype == 'object':
df[col] = df[col].apply(lambda x: clean_player_name(x) if isinstance(x, str) else x)
return export_df, df
except Exception as e:
st.error(f'Error loading file: {str(e)}')
return None
return None |