Python Forum
invalid literal for int() with base 10: ''
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
invalid literal for int() with base 10: ''
#1
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?
# 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
Reply


Messages In This Thread
invalid literal for int() with base 10: '' - by mrsenorchuck - Dec-03-2019, 03:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: invalid literal for int() with base 10: omega_elite 5 5,809 Dec-30-2020, 06:11 AM
Last Post: delonbest
  invalid literal for int() with base 10: '# NRECS: 1096\n' Baloch 8 4,561 May-24-2020, 02:08 AM
Last Post: Larz60+
  ValueError: invalid literal for int() with base 10: '\n' srisrinu 9 5,773 Apr-13-2020, 01:30 PM
Last Post: ibreeden
  zlib decompress error: invalid code lengths set / invalid block type DreamingInsanity 0 6,872 Mar-29-2020, 12:44 PM
Last Post: DreamingInsanity
  input-ValueError: invalid literal for int() jacklee26 2 2,556 Feb-21-2020, 01:27 PM
Last Post: ndc85430
  ValueError: invalid literal for int() with base 10: '0.5' emmapaw24 2 3,747 Feb-16-2020, 07:24 PM
Last Post: emmapaw24
  ValueError: invalid literal for int() with base 10: '' Jay123 7 7,299 Aug-05-2019, 02:43 PM
Last Post: Jay123
  ValueError: invalid literal for int() with base 10: '' ivinjjunior 6 9,154 Apr-20-2019, 05:37 PM
Last Post: keames
  Problem with "invalid literal for int() with base 10: '' jirkaj4 4 10,460 Jan-23-2018, 06:55 PM
Last Post: jirkaj4
  ValueError: invalid literal for int() with base 10: '[2,4,7,8,19]' rajeev1729 3 60,715 Sep-15-2017, 05:51 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020