I am using python xlwings to read a column of data in Excel 2013. Column A
is populated with numbers. To import this column into a python list py_list
, I have the following code;
import xlwings as xw
wb = xw.Book('BookName.xlsm')
sht = xw.Book('SheetName')
py_list = sht.range('A2:A40').value
The above code works if the column data is populated at A2:A40
. However, the column data can keep growing. Data can grow and stretch to A2:A46
or A2:A80
. The last row is empty. It is not known at compile time how many rows of data is in this column.
How can I modify the code to detect the empty cell at the last row so that the range of data can be read by py_list
?
I am open to using other python libraries to read the Excel data besides xlwings. I am using python v3.6