excel - Python - XLSXWriter writes character per column -


assuming have following code snippet , ordered_list containing values appended together, 1 row of contents printed out on test in format:

[text:u'lt4974', text:u'mrnameid', number:14, number:121]

if didn't enclose row in str() method, different error occur. result output file writes every character per column... wrong. how correctly write in such way following contents in respective columns?

col1 || col2 || col3 || col4

lt4974 || mrnameid || 14 || 121

new_workbook = xlsxwriter.workbook() sheet = new_workbook.add_worksheet('test')  row_index, row in enumerate(ordered_list):     #for col_index, cell_value in enumerate(row):         sheet.write_row(row_index, 0, str(row))  new_workbook.save('output.xlsx') 

1.) if try uncommenting for col_index, cell_value in enumerate(row) , change str(row) str(cell_value) still write per character , time not getting values falls text.

2.) if try directly give row in : sheet.write_row(row_index, 0, row) error typeerror: unsupported type <class 'xlrd.sheet.cell'> in write()

you can add 1 more loop write different columns needed

new_workbook = xlsxwriter.workbook() sheet = new_workbook.add_worksheet('test')  row_index, row in enumerate(ordered_list):         col_index,item in enumerate(row):             sheet.write_row(row_index, col_index, str(item))  new_workbook.save('output.xlsx') 

kindly lemme know if change helps you


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 -