This is the next step in my currently unresolved question in which I am attempting to sort the scores from 3 different teams. I have very limited knowledge of python because I am new to programming so my problem solving of this current project is quite difficult.
To begin I will need the example data (shown below) which are split over two cells to be sorted alphabetically according to the names, I will have this for 3 different teams in 3 different files. I am also trying to sort it out from highest to lowest depending on the score, this has proven of much difficulty to me so far.
Jake,5
Jake,3
Jake,7
Jeff,6
Jeff,4
Fred,5
The third and final way to sort I am trying to do is by average. For this I had attempted to make it so if the user had there name 2 or 3 times (as the program will store the last 3 scores for each user, this is a currently unresolved problem) then it would add their scores then divide by how many of them it had there. Unfortunately this was very difficult for me and i struggled to be able to get any output, though I had an idea that this will print their average scores to a separate file then re-read the scores.
The current layout I have so far is shown below:
admin_data = []
team_choice = input("Choose a team to sort")
if team_choice == 'Team 1':
path = 'team1scores.csv'
elif team_choice == 'Team 2':
path = 'team2scores.csv'
elif team_choice == 'Team 3':
path = 'team3scores.csv'
else:
print("--Error Defining File Path--")
print("As an admin you have access to sorting the data")
print("1 - Alpahbetical")
print("2 - Highest to Lowest")
print("3 - Average Score")
admin_int = int(input("Choose either 1, 2 or 3?"))
if sort_int == 1 and team_choice == 'Team 1':
do things
elif sort_int == 2 and team_choice == 'Team 1':
do things
elif sort_int == 3 and team_choice == 'Team 1':
do things
This part of the program will be used for each file, but have had no luck producing any solutions for each of the different sorting ways I need. I will also appreciate if the answer for the first part of my project is answered too.
EDIT (16:43): I have managed to complete the highest to lowest part of the program but is printing:
[['Fred', '9'], ['George', '7'], ['Jake', '5'], ['Jake', '4'], ['Derek', '4'], ['Jake', '2']]
So if this is the formatting I read the data as, how will I be able to read the file for duplicate names and add the scores if they are in arrays like this?