excel - Python - TypeError: 'Cell' object is not iterable -


what i'm trying write new excel file data list. contents of list row contents i'm trying write in new excel file using xlsxwriter (specifically xlsx because i'm using xlsx). assuming have code snippet below, yields me error :

typeerror: 'cell' object not iterable

the whole stacktrace points out during write event.

traceback (most recent call last): file "desktop/excel-copy.py", line 33, in <module>     sheet.write_row(row_index, col_index, cell_value)   file "/usr/local/lib/python2.7/dist-packages/xlsxwriter/worksheet.py", line 64, in cell_wrapper     return method(self, *args, **kwargs)   file "/usr/local/lib/python2.7/dist-packages/xlsxwriter/worksheet.py", line 989, in write_row     token in data: typeerror: 'cell' object not iterable   import xlrd import xlsxwriter  new_workbook = xlsxwriter.workbook() sheet = new_workbook.add_worksheet('stops')  #copy row , column contents new worksheet row_index, row in enumerate(ordered_list_stops):     col_index, cell_value in enumerate(row):         print("writing: " + str(cell_value) + "at " + str(row_index)+ " " + str(col_index))         sheet.write_row(row_index, col_index, cell_value)  new_workbook.save('output.xlsx') 

i can't quite point out whether cell_value cause. tried printing out , result:

writing: text:u'4977'at 0 0

the problem write_row takes list (or other iterable) of values, , you're passing single cell object (cell_value) instead.

you either want use sheet.write(row_index, col_index, cell_value), or skip inner for loop , use sheet.write_row(row_index, 0, row)


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -