Following the response in this thread. I prepared the following code.
from xlrd import open_workbook
def main():
book = open_workbook('/dir/file.xlsx', index_col=0)
sheet = 'Sheet1'
collection_year_col = 'Unnamed: 2'
test_year = 2011
for row in range(sheet.nrows=7):
if sheet.cell(row,collection_year_col).value == test_year:
runCode()
def runCode():
print("worked!")
It runs and gives no error, but never outputs the print()
.
Why is that and how can I fix it? My value of interest is "2011" and is found in cell C7 of my Excel file.
I suspect the issue is my (bad?) syntax to refer to row 7.