ValueError: too many values to unpack

Laszlo Nagy gandalf at designaproduct.biz
Wed Apr 11 15:57:46 EDT 2007


> Hmm, well I have counted the fields in the CSV and verified there are
> only 11. Here is the offending code:
>
>   
....


Try this instead:

lineno = 0
for values in csvreader:
    try:
       lineno += 1
       boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, 
address,phone, country, city = values
    except:
       print "Problem at line #",lineno
       print repr(values)
       break

Or even:

lineno = 0
for values in csvreader:
       lineno += 1
       if len(values) != 11:
         print "Problem at line #",lineno
         print repr(values)

Best,

   Laszlo




More information about the Python-list mailing list