Reputation: 1561
I am trying to see if I could enter values of an array into a spreadsheet using xlsxwriter module. Given below is a view of the array I am working with:
0(5339, '2017-09')
1(670, '2017-10')
2(3268, '2017-11')
3(7645, '2017-12')
4(9999, '2018-01')
5(11987, '2018-02')
6(14354, '2018-03')
7(15782, '2018-04')
8(15465, '2018-05')
9(1473, '2018-06')
10(1661, '2018-07')
11(5679, '2018-08')
12(6927, '2018-09')
Could anyone assist, thanks..
Upvotes: 0
Views: 2197
Reputation: 348
workbook = xlsxwriter.Workbook('YOUR_FILE.XLSX')
worksheet = workbook.add_worksheet()
# Start from the first cell row 0 and column 0
row = 0
col = 0
# Iterate through the array you have and unpack the tuple at each index
for elm1, elm2 in your_array:
worksheet.write(row, col, elm1)
worksheet.write(row, col + 1, elm2)
row += 1
workbook.close()
Upvotes: 2