How can I get number of rows for my loop?
Closed this issue · 2 comments
lucielavickova commented
Hello, I am trying to loop through the rows in my excel file, but unfortunately could not find any keyword to get the number of rows... or is there any other way how to create a FOR cycle using this library? Thanks
ailjushkin commented
Hi, the read_excel_column
keyword returns all rows of a whole column.
Here's how you can get length of columns rows:
from ExcelLibrary import ExcelLibrary
e = ExcelLibrary()
e.open_excel_document('test.xlsx', doc_id='test.xlsx')
col = e.read_excel_column(0)
print(len(col))
Or in *.robot style:
Library Collections
Library ExcelLibrary
...
${col}= ExcelLibrary.read_excel_column col_num=0
${length}= Collections.Get Length ${col}
You can also get rows count working with a sheet object:
from ExcelLibrary import ExcelLibrary
e = ExcelLibrary()
e.open_excel_document('test.xlsx', doc_id='test.xlsx')
print(len(list(e.get_sheet().rows)))
ailjushkin commented
I close the task because the consultation was received.