I m trying to write some data in an excel file.
rounds= [[(0, 2), (1, 3)], [(2, 0), (1, 3)], [(2, 1), (0, 3)], [(0, 3), (2, 1)], [(3, 0), (1, 2)], [(2, 0), (3, 1)]]
And I want to write them in a list as below: (round is the index of the sub-list they belong)
pl1 | pl2 | round |
---|---|---|
0 | 2 | 0 |
1 | 3 | 0 |
2 | 0 | 1 |
1 | 3 | 1 |
2 | 1 | 2 |
0 | 3 | 2 |
and so on.....
I'm trying to move the data to the excel file using xlxswrite, but I get this error
(Please, ignore that I don't put headers in excel columns, I know)
import xlsxwriter
workbook = xlsxwriter.Workbook("table.xls")
worksheet = workbook.add_worksheet()
rounds= [[(0, 2), (1, 3)], [(2, 0), (1, 3)], [(2, 1), (0, 3)], [(0, 3), (2, 1)], [(3, 0), (1, 2)], [(2, 0), (3, 1)]]
for index,entry in enumerate(rounds):
for pairing in entry:
worksheet.write(index,0,pairing(0))
worksheet.write(index,0,pairing(1))
worksheet.write(index,0,str(index))
But I get the error :
worksheet.write(index,0,pairing(0))
TypeError: 'tuple' object is not callable
How can I access the data of each tuple then?