0

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..

1
  • What did you try so far and what didn't work? Commented Sep 5, 2018 at 14:44

1 Answer 1

2
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()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.