1

I have the following list output data in Python and would like to export it into a spreadsheet

data = [list[1], list[2], list[3]]

I want the following output to display as separate columns in excel

List1 List2  List3
['A', 'Test', '3rd Column']
['B', 'Test1', '3rd Column']
['A', 'Test2', '3rd Column']
Pen7865
  • 51
  • 1
  • 5
  • 1
    Welcome to Stack Overflow! You seem to be asking for someone to write some code for you. Stack Overflow is a question and answer site, not a code-writing service. Please [see here](http://stackoverflow.com/help/how-to-ask) to learn how to write effective questions. – Yevhen Kuzmovych Nov 03 '21 at 10:33
  • This [answer](https://stackoverflow.com/questions/14037540/writing-a-python-list-of-lists-to-a-csv-file) might help you. – steTATO Nov 03 '21 at 10:36

1 Answers1

1

You can use library xlsxwriter https://xlsxwriter.readthedocs.io/getting_started.html that will allow you to easily export dataframe to excel format

import pandas as pd

list1 = ['A', 'Test', '3rd Column']
list2 = ['B', 'Test1', '3rd Column']
list3 = ['A', 'Test2', '3rd Column']

data = [list1, list2, list3]

df = pd.DataFrame(data, columns=['List1', 'List2', 'List3']) 
writer = pd.ExcelWriter(file_path, engine='xlsxwriter')
df.to_excel(writer, 'Sheet name')
workbook = writer.book
worksheet = writer.sheets['Sheet name']
writer.save()
Patrick
  • 1,189
  • 5
  • 11
  • 19