2

I'm trying to copy data to an excel file using xlwt in a python code

  worksheet.write(globdat.cycle,1,fint)

globdat.cycle is a count. No problems there since it gets values 1, 2.... n in each iteration.

BUT

'fint' is an array with an unknown number of entries so I cannot exactly give the number of columns.

How can I be able to copy all the values in 'fint' to the excel file ?

dyon
  • 31

1 Answers1

2

You need to loop the array and call worksheet.write for each item. You have to specify which row/column you're writing to so we can use the builtin enumerate to count out each item in the array.

You want something like this:

for i, fintitem in enumerate(fint, start=1):
    worksheet.write(globdat.cycle, i, fintitem)
Oli
  • 299,380