I have a list of row numbers and I want to loop through that list using xlrd python module to look into those rows and column 3 and save the value from those cells in a new variable.
Here is what I have so far:
rows_exceptions_file_final = [ 2, 5, 6 , 8, 11, 15 ]
rows_string = []
for i in rows_exceptions_file_final:
rows_string.append(sheet2.cell_value( i , 3))
The exception I am getting is:
cell_value return self._cell_values[rowx][colx] IndexError: list index out of range
I was I adding + 1 to every number in the list because enumerate function I used before. Since enumerate starts from 0 and my rows start from 1, but after removing that +1 function everything works fine with the code in the question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.