How to write a list of list into excel using python?
You can use the pandas library.
import pandas as pd
new_list = [["first", "second"], ["third", "four"], ["five", "six"]]
df = pd.DataFrame(new_list)
writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')
df.to_excel(writer, sheet_name='welcome', index=False)
writer.save()
Related documentation:
pandas.ExcelWriter
pandas.DataFrame
pandas.DataFrame.to_excel
Here is one way to do it using XlsxWriter:
import xlsxwriter
new_list = [['first', 'second'], ['third', 'four'], [1, 2, 3, 4, 5, 6]]
with xlsxwriter.Workbook('test.xlsx') as workbook:
worksheet = workbook.add_worksheet()
for row_num, data in enumerate(new_list):
worksheet.write_row(row_num, 0, data)
Output: