I would like to write each value in a Python list to a new row in an Excel cell. The object I am generating the list from does not support indexing which is giving me an issue. If my list only generates one value, then there is no problem, however when I generate multiple values, I get multiple errors. I am a Python beginner using 64 bit OS X and Python 2.7. Any help would be much appreciated.
import mlbgame
month = mlbgame.games(2016, 7, 21, home ="Pirates")
games = mlbgame.combine_games(month)
for game in games:
print(game)
import xlwt
from datetime import datetime
wb = xlwt.Workbook()
ws = wb.add_sheet('PiratesG')
for game in games:
ws.write(0, 0, str(game))
#ws.write(1, 0, str(game[1]))
wb.save('Pirates.xls')
Error: Traceback (most recent call last):
File "/Users/Max/Code/PiratesGameToExcel.py", line 14, in <module>
ws.write(0, 0, str(game))
File "/usr/local/lib/python2.7/site-packages/xlwt/Worksheet.py", line 1088, in write
self.row(r).write(c, label, style)
File "/usr/local/lib/python2.7/site-packages/xlwt/Row.py", line 241, in write
StrCell(self.__idx, col, style_index, self.__parent_wb.add_str(label))
File "/usr/local/lib/python2.7/site-packages/xlwt/Row.py", line 160, in insert_cell
raise Exception(msg)
Exception: Attempt to overwrite cell: sheetname=u'PiratesG' rowx=0 colx=0