0

I am new to python and looking for some help.

I am trying to read values from an excel file and return some values as a tuple from the function. I am able to return all values except the date.

I am getting the error :

invalid literal for int() with base 10: '10/12/2017 21:05'

This is the relevant part of the code:

sdndate = data[i][j]
sdndate = xlrd.xldate_as_datetime(sdndate, 0)
outputTuple = (var1, var2, sdndate)

I understand that there some problem with variable type for date, but I am not able to fix it.

Thanks.

ZdaR
  • 22,343
  • 7
  • 66
  • 87
Divya
  • 33
  • 4
  • Possible duplicate of [How to convert a Python datetime object to seconds](https://stackoverflow.com/questions/7852855/how-to-convert-a-python-datetime-object-to-seconds) – ZdaR Oct 27 '17 at 12:13
  • The date in my excel is "10/12/2017 21:05" when i read it using xlrd object it gets converted to a string. I want my tuple to "10/12/2017 21:05" as a single element. – Divya Oct 27 '17 at 12:16
  • As per the [documentation](http://xlrd.readthedocs.io/en/latest/api.html#xlrd.xldate.xldate_as_datetime), this method returns a `datetime` object not a `str` object, which you are expecting to be `int` in this case. – ZdaR Oct 27 '17 at 12:19
  • You are passing in a string, not an `xldate`. – aaron Oct 27 '17 at 12:49

0 Answers0