I am working with a CSV file with multiple rows, which I need to be able to access individual data elements from a row so I can assign them to variables and send them to the other program I am working with in a loop, going through each individual row.
I was previously working on a program originally written by another developer which used this
for i, record in enumerate(reader):
if i > 1: # dump first two
blah1, blah2, blah3, blah4, blah5, blah6, blah7, \
blah8, blah9, blah10, blah11, blah12, blah13, blah14, \
blah14, blah15, blah16, blah17, blah18= record
to take the rows out and collect the individual data items from each. This all worked fine and I thought my understanding of the concept was enough that I could duplicate it in a similar program I am now writing from scratch.
My code for this section in the new program is as follows:
for i, record in enumerate(reader):
if i > 0: #skip headers
date, hk, ba, bsp, hgch, v995, v996, vct = record
When I run the code in cmd, I get an error message that reads
ValueError: unpack list of wrong size
I have looked into this briefly but haven't had much luck in applying solutions to my own problem.
If anyone can offer any insight to either reading csv files or the trouble with my code, that would be greatly appreciated.