ValueError: too many values to unpack

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 11 15:57:11 EDT 2007


En Wed, 11 Apr 2007 16:28:08 -0300, fscked <fsckedagain at gmail.com>  
escribió:

>> Trying to use CSV to read in a line with 11 fields and I keep getting
>> this error. I have googled a bit and have been unable to figure it
>
> myfile = open('ClientsXMLUpdate.csv')
> csvreader = csv.reader(myfile)
>
> for boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, address,
> phone, country, city in csvreader:
> 	mainbox = SubElement(root, "{Boxes}box")
>     [...]

You say all rows have 11 fields, the csv module insists on an error... try  
using some print statements to see who is right:

for index, items in enumerate(csvreader):
     print index, len(items)
     if len(items)!=11: print items


-- 
Gabriel Genellina



More information about the Python-list mailing list