Going through a xlsx spreadsheet by column in Python
Most examples iterate by row. This one iterates by col.
import xlrd workbook = xlrd.open_workbook('test_file.xlsx') worksheet = workbook.sheet_by_index(0) num_cols = worksheet.ncols - 1 curr_col = -1 while curr_col < num_cols: #Iterate through cols curr_col += 1 col = worksheet.col(curr_col) for cell in col: #Iterate through cells in col print cell.value
Leave a Reply