Nov-25-2019, 02:58 PM
(Nov-25-2019, 10:51 AM)perfringo Wrote: You should modify filter provided by Dead_EyE according to your needs.
Thank you for your reply.
So Dead_EyE's code can be used to filter down the records in a data dictionary?
How can I apply this to my code below?
Is it possible to sum a value like 'Win' or would I have to add all win rows to list to do this?
premier = {} print() # open the file with open(r"Historic_PL.csv") as data_file: # read in the first line containing the headers headers = data_file.readline() # for each other line in the file for line in data_file: # split each line into components (remove white space from ends of line) Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best = line.strip().split(",") # insert the data into the dictionary premier[int(Pos)] = (Club,int(Seasons),int(Pld),int(Win),int(Draw),int(Loss),int(GF),int(GA),int(GD),int(Pts),int(First),int(Second),int(Third),int(Fourth),int(Relegated),int(Best))Pos,Club,Seasons,Pld,Win,Draw,Loss,GF,GA,GD,Pts,First,Second,Third,Fourth,Relegated,Best
1,Manchester United,27,1038,648,224,166,1989,929,1060,2168,13,6,3,1,0,1
2,Arsenal,27,1038,565,260,213,1845,1013,832,1955,3,6,5,7,0,1
3,Chelsea,27,1038,558,257,223,1770,1002,768,1931,5,4,5,2,0,1
4,Liverpool,27,1038,529,262,247,1774,1046,728,1849,0,4,5,7,0,2
5,Tottenham Hotspur,27,1038,446,257,335,1547,1306,241,1595,0,1,2,3,0,2