Please find following code that tries to read integer values from XLS files.
import xlrd
import sys
def print_sheet(sheet):
for row_ind in xrange(sheet.nrows):
print '\t'.join([unicode(x) for x in sheet.row_values(row_ind)]).encode('utf-8')
f = xlrd.open_workbook('main.xls')
print_sheet(f.sheet_by_index(0))
The example Excel file is as:
1 3
2 4
But the code will convert the integer into float, the output will be:
1.0 2.0
3.0 4.0
Could someone help me keep integers in xlrd? Thanks.