upload an excel file and read the data
In my application, I uploaded an excel file and trying to read the data. I am trying in following way,
@expose()
def save(self, **params):
xls_file = params['xls_file']
wb = xlrd.open_workbook(bill_file,'w')
sh = wb.sheet_by_index(0)
for i,rownum in enumerate(range(sh.nrows)):
print sh.row_values(rownum)
But getting the following errors:
TypeError: coercing to Unicode: need string or buffer, instance found
Module xlrd:425 in open_workbook view << encoding_override=encoding_override, formatting_info=formatting_info, on_demand=on_demand, ) t1 = time.clock()
on_demand=on_demand, Module xlrd:878 in biff2_8_load view << 开发者_如何转开发 retry = False try: f = open(filename, open_mode) except IOError: e, v = sys.exc_info()[:2] f = open(filename, open_mode)
enumerate() is already returning pairs (index, item). The range() call is completely unnecessary.
精彩评论