R
R
Roma32343432022-02-15 20:18:42
excel
Roma3234343, 2022-02-15 20:18:42

openpyxl. How to count the number of elements in a particular column without a loop in EXEL?

620be04d7e586741428016.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PavelMos, 2022-02-15
@PavelMos

Just like using the list generator, check the number of certain elements in the list by measuring the length of the filtered list
. An empty cell in the openpixel is None

l=[wb['Sheet1']
['B'+str(row)].value for row in range (2, wb['Sheet1'].max_row+1) 
if (wb['Sheet1']['B'+str(row)].value)!=None]
len (l)

if you need to iterate through all the columns, then through a loop in which the cell addresses will change - A, B, C ...
Or make a nested list generator by letters of the columns

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question