AK9309 AK9309 - 5 months ago 28
Python Question

Working with openpyxl. making a list out of a column

I am working with a big excel file.
I am using

wb = load_workbook(filename='my_file.xlsx')
ws = wb['Sheet1']


I don't want to alter the worksheet in any way. I just want to take data from several columns and work with them.
My understanding is that I can't just call a column and use
.tolist()
because all the values are stored in excel.

Answer

Based on your comment here's one thing you can do:

mylist = []
for col in ws.columns[0]:
    mylist.append(col.value)