I am trying to get my cell values (ticker symbols) from the excel sheet, but cannot figure out how to specify rows/columns to use. The ws.iter_rows() method is not accepting the string.
wb = openpyxl.load_workbook('/Users/SPAC_price_data.xlsx')
ws = wb['Common share price history']
for row in ws.iter_rows('A1:A36'):
for cell in row:
print(str(cell.value))
The error is:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-7fdf6dd1581e> in <module>
1 if __name__ == "__main__":
----> 2 main()
<ipython-input-3-d2cdb2b8ed38> in main()
16 wb = openpyxl.load_workbook('/Users/SPAC_price_data.xlsx')
17 ws = wb['Common share price history']
---> 18 for row in ws.iter_rows('A1:A36'):
19 for cell in row:
20 print(cell.value)
/Applications/anaconda3/lib/python3.8/site-packages/openpyxl/worksheet/worksheet.py in _cells_by_row(self, min_col, min_row, max_col, max_row, values_only)
442
443 def _cells_by_row(self, min_col, min_row, max_col, max_row, values_only=False):
--> 444 for row in range(min_row, max_row + 1):
445 cells = (self.cell(row=row, column=column) for column in range(min_col, max_col + 1))
446 if values_only:
TypeError: 'str' object cannot be interpreted as an integer