1

I have a spreadsheet of data I am parsing using openpyxl's iter_rows function. However when I loop through the sheet using:

range_expr = "{col}{startrow}:{col}{endrow}".format(col='C',startrow=4,endrow=ws.get_highest_row()+1)

for row in ws.iter_rows(range_string=range_expr):
    print row
    if len(row) > 0:
        cell = row[0]
        if str(cell.value).isdigit():
            address.append(cell.value)
        else:
            continue
print address
raw_input("enter to continue")

the 3rd line just spews out empty parenthesis, which means the first if statement will always evaluate false, and no values will append to address. What I'm confused about is why print row does nothing, when there is data in the excel document. Thanks in advance everyone.

2
  • What Excel version is this operating on? Jun 21, 2012 at 19:28
  • Excel 2007, openpyxl 1.5.8, python 2.7.3, windows 7 Jun 21, 2012 at 19:34

1 Answer 1

0

I was overcomplicating things, and simplified it to this. Many thanks to notbad.jpg on the Python chat room:

range_expr = 'C:C'

for row in ws.iter_rows(row_offset=4):
    '''do things'''

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.