-1

I will just keep it short and simple . I have a two dimensional list that i would like to import to excel spreedsheet or a csv ? Here is my 2d list below.

'df = [[3, 7, 9, 28],[3, 7, 17, 28],[7, 25, 27, 28],[7, 17, 21, 27, 28],[3, 4, 28],[4, 7, 28],[4, 7, 14, 28],[3, 14, 28],[3, 7, 14, 28],[7, 11, 28],[3, 11, 28],[3, 7, 12, 28],[7, 11, 12, 28],[3, 11, 12, 28],[3, 7, 11, 28]]'

Chris88
  • 53
  • 8
  • Possible duplicate of [Python How to use ExcelWriter to write into an existing worksheet](https://stackoverflow.com/questions/34744863/python-how-to-use-excelwriter-to-write-into-an-existing-worksheet) – Thomas Lang Oct 07 '19 at 17:36

1 Answers1

1

Here is a simple approach that might work on your end :)

df = [[3, 7, 9, 28],[3, 7, 17, 28],[7, 25, 27, 28],[7, 17, 21, 27, 28],[3, 4, 28],[4, 7, 28],[4, 7, 14, 28],[3, 14, 28],[3, 7, 14, 28],[7, 11, 28],[3, 11, 28],[3, 7, 12, 28],[7, 11, 12, 28],[3, 11, 12, 28],[3, 7, 11, 28]]


import csv

with open('myspreadsheet.csv', 'w', newline = '') as fp:
    writer = csv.writer(fp, delimiter = ',')
    for row in df:
        writer.writerow(row)