|
@@ -124,13 +124,19 @@ def load_scores():
|
|
|
with open("all_scores.txt", "r") as f:
|
|
with open("all_scores.txt", "r") as f:
|
|
|
lines = f.readlines()
|
|
lines = f.readlines()
|
|
|
for line in lines:
|
|
for line in lines:
|
|
|
- name, score = line.strip().split(",")
|
|
|
|
|
- score = float(score)
|
|
|
|
|
- names.append(name)
|
|
|
|
|
- scores.append(score)
|
|
|
|
|
- if score > highestScore:
|
|
|
|
|
- highestScore = score
|
|
|
|
|
- highScoreName = name
|
|
|
|
|
|
|
+ line = line.strip()
|
|
|
|
|
+ if line and "," in line: # Check if line is not empty and contains a comma
|
|
|
|
|
+ try:
|
|
|
|
|
+ name, score = line.split(",")
|
|
|
|
|
+ score = float(score)
|
|
|
|
|
+ names.append(name)
|
|
|
|
|
+ scores.append(score)
|
|
|
|
|
+ if score > highestScore:
|
|
|
|
|
+ highestScore = score
|
|
|
|
|
+ highScoreName = name
|
|
|
|
|
+ except (ValueError, IndexError):
|
|
|
|
|
+ # Skip malformed lines
|
|
|
|
|
+ continue
|
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
|
# Create the file if it doesn't exist
|
|
# Create the file if it doesn't exist
|
|
|
with open("all_scores.txt", "w") as f:
|
|
with open("all_scores.txt", "w") as f:
|