受到Read a UTF8 CSV file with Python的公认答案的启发,我尝试了以下方法,但得到了
ValueError: need more than 5 values to unpack
似乎空字符串在这里绊倒了我。我应该申请一个功能来row
完成这项工作吗?我需要进一步单独处理这些变量。谢谢。
def encodevar(x):
return x
row = ['85123', '', '123 The Address', '', '', 'TUCSON', 'AZ ', 'The Company Name', '', '']
for zip5,zip4,strname,strnumber,strsuite,city,state,busname,lname,fname in row:
HHid = encodevar( zip5 ) +\
encodevar( zip4 ) +\
encodevar( stname ) +\
encodevar( stnumber ) +\
encodevar( stsuite ) +\
encodevar( busname )