James McCool
commited on
Commit
·
ba217a9
1
Parent(s):
d9d478e
Refactor lineups file handling in load_dk_fd_file.py: clean up line name by removing numeric suffixes using regex, and streamline CSV file loading by removing UTF-8 encoding specification for improved compatibility.
Browse files
global_func/load_dk_fd_file.py
CHANGED
@@ -3,6 +3,7 @@ import numpy as np
|
|
3 |
import pandas as pd
|
4 |
import time
|
5 |
from fuzzywuzzy import process
|
|
|
6 |
|
7 |
def load_dk_fd_file(lineups, csv_file):
|
8 |
df = csv_file.copy()
|
@@ -13,10 +14,11 @@ def load_dk_fd_file(lineups, csv_file):
|
|
13 |
|
14 |
# Now load and process the lineups file
|
15 |
try:
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
lineups_df = pd.read_excel(lineups)
|
21 |
else:
|
22 |
st.error('Please upload either a CSV or Excel file for lineups')
|
|
|
3 |
import pandas as pd
|
4 |
import time
|
5 |
from fuzzywuzzy import process
|
6 |
+
import re
|
7 |
|
8 |
def load_dk_fd_file(lineups, csv_file):
|
9 |
df = csv_file.copy()
|
|
|
14 |
|
15 |
# Now load and process the lineups file
|
16 |
try:
|
17 |
+
clean_name = re.sub(r' \(\d+\)', '', lineups.name)
|
18 |
+
|
19 |
+
if '.csv' in clean_name:
|
20 |
+
lineups_df = pd.read_csv(lineups)
|
21 |
+
elif any(ext in clean_name for ext in ['.xls', '.xlsx']):
|
22 |
lineups_df = pd.read_excel(lineups)
|
23 |
else:
|
24 |
st.error('Please upload either a CSV or Excel file for lineups')
|