I'm trying to printout a few cell contents using the XLRD package in Python 2.7 using the Spyder IDE to create a script. I'm seeing a syntax error while using the command print sheet.cell_value() on the IDE while it seems to return correct values when used from the windows command prompt. The error message I see is below:
print sheet.cell_value(0, col)
^
SyntaxError: invalid syntax
My code:
from __future__ import print_function
import xlrd
file_name="C:/Users/Documents/Python Learn/1.xlsx"
workbook=xlrd.open_workbook(file_name)
sheet=workbook.sheet_by_index(0)
NumberOfRows=sheet.nrows
NumberOfColumns=sheet.ncols
for col in range(sheet.ncols):
print sheet.cell_value(0, col)