I am working on my Python project and I'm stuck on a for loop. Basically, I need to conditionally count cells in a column (bank_account) where the cells are populated, omitting empty cells and cells starting with '00000'.
Here's part of the code:
sheets = vendor_list.sheetnames
NIP_col = locate_col(vendor_list, sheets[0], 'VTID05')
bank_account_col = locate_col(vendor_list, sheets[0], 'BKAC05')
vendor_list_data_dict = {"VTID05":[],"BKAC05":[]}
for y in range(100000):
bank_account_item_ID = str(vendor_list['Sheet1'].cell(row=2+y, column=bank_account_col).value)
if bank_account_item_ID != "None" and str(bank_account_item_ID).startswith('00000'):
vendor_list_data_dict["BKAC05"].append(
str(vendor_list['Sheet1'].cell(
row=2+y, column=bank_account_col).value).replace(" ",""))
else:
pass
Result I get is number of cells starting with '00000'. Why? How do I fix this to count only populated cells with bank account numbers, without empty cells and cells starting with '00000'?