from xlrd import open_workbook
book = open_workbook('Workbook2.csv')
sheet = book.sheet_by_index(0)
keys = [sheet.cell(0,col_index).value for col_index in xrange(sheet.ncols)]
dict_list =[]
for row_index in xrange(1,sheet.nrows):
d={keys[col_index]: sheet.cell(row_index, col_index).value for col_index in xrange(sheet.ncols)}
dict_list.append(d)
print dict_list
for i in range(len(dict_list)):
for key,val in dict_list[i]:
print val
試圖打印出val,但它給出了這個錯誤:ValueError:太多的值來解壓縮。任何人都可以幫忙?在這個錯誤上需要幫助:ValueError:太多的值來解壓
'for key,val in dict_list [i] .items()'? –
CSV的內容是什麼? – Rich