Python xlrd package issue -


is there way overcome next problem: when using xlrd package in python, value '1' in excel file shows '1.0'.

now, writing script should able notice difference, using values indexes, '1' , '1.0' different indexes, cant find way overcome issue.

is there can do?

thanks.

yes, common problem xlrd. need convert int, when number of int type , rest of times need float itself.

so here works out in cases:

 int_value = int(float_value)  if float_value == int_value:      converted_value = int_value  else:      converted_value = float_value 

example

>>> = 123.0 >>> type(a) <type 'float'> >>> b = int(a) >>> == b true 

Comments