[Python] Read specific columns from excel for python

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    import xlrd

    workbook = xlrd.open_workbook(filename)
    sheet = workbook.sheet_by_index(0)

    array = []
    for i in range(2, 9):
    array.append([sheet.cell(i, j).value for j in range(2, 5)])


    Excel Image

    I have this code and it works fine, but it's not doing what I want it to do. It is pulling the data from all the three columns of that excel file (see excel image). I only want it to pull data from column C and column E, and store that as a pair in the array. How to do that? I know there is something like skip columns and skip rows in python, but not sure how to embed that in the code I have.

    Continue reading...

Compartilhe esta Página