Dec-03-2019, 03:48 PM
Getting an error "invalid literal for int() with base 10: ''" on the line where I assign the keys.
What is the best way to debug?
What is the best way to debug?
# dictionary keys will be the (Club and year) premier = {} print() # open the file with open(r"League_Table.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) Team,Pos,Pld,HW,HD,HL,HG,HC,AW,AD,AL,AG,AC,W,D,L,G,C,DF,Pts,Champ,Rel,Year = line.strip().split(",") # insert the data into the dictionary premier[str(Team),int(Year)] = ((int(Pos), int(Pld), int(HW), int(HD), int(HL), int(HG), int(HC), int(AW), int(AD), int(AL), int(AG), int(AC), int(W), int(D), int(L), int(G), int(C), int(DF), int(Pts), Champ, Rel))
Output:Team,Pos,Pld,HW,HD,HL,HG,HC,AW,AD,AL,AG,AC,W,D,L,G,C,DF,Pts,Champ,Rel,Year
Manchester United,1,42,14,5,2,39,14,10,7,4,28,17,24,12,6,67,31,36,84,Yes,No,1993
Aston Villa,2,42,13,5,3,36,16,8,6,7,21,24,21,11,10,57,40,17,74,No,No,1993
Norwich City,3,42,13,6,2,31,19,8,3,10,30,46,21,9,12,61,65,-4,72,No,No,1993