ValueError python

Please, I'm trying to output a date, revenue and machine, writing on excel.

From the input string:

B1 = 20,00

The coding:

i = 0
for info in a:
   if len(info.split('/')) == 2: #Call date
        datestr = info[0:5] + "/2018"
        date = datetime.datetime.strptime(datestr, '%d/%m/%Y') #Find date
   elif info[0].find("B") == 0: #Get Machine B
       if info[7] == ",":
           revenue = info[5:10]
       elif info[8] == ",":
           revenue = info[5:11]
       elif info[6] == ",":
           revenue = info[5:9]
       if info[1].find("1") == 0:
           machine = "Machine B1"
           sheet1.write(i,0,date, date_format)
           i = i+1

However, We're getting the following error:

Traceback (most recent call last):
  File "C:\Users\Ricardo\Documents\Python Scripts\WHR Snacks to Go\", line 64, in <module>
    sheet1.write(i,0,date, date_format)
  File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\xlwt\", line 1088, in write
    self.row(r).write(c, label, style)
  File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\xlwt\", line 1142, in row
    self.__rows[indx] = self.Row(indx, self)
  File "C:\Users\Ricardo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\xlwt\", line 37, in __init__
    raise ValueError("row index was %r, not allowed by .xls format" % rowx)
ValueError: row index was '\n', not allowed by .xls format


comments powered by Disqus