I want to do this:
while list:
for blah in blah:
things
list.remove(min(list))
Would this loop until all the items in list are removed? As i have it my code, it just loops through [list] times, and then returns from the function. I need a loop that will keep going until all the items of list are gone.
I should note, nothing inbetween (in the for loop) is processed until the last iteration.
By request, the entire algorithm as it runs:
def parsexlsx(address):
bits = []
i = 0
while address:
min_address = False
for row in ws.iter_rows(row_offset=4,column_offset=3):
c = row[2]
d = row[3]
if not d.internal_value:
if min_address: #we set it to true, then kept going until blank row
break #bits is what you want it to be now
bits = [] #reset bits every time we hit a new row
continue #this will just skip to next row
for bits_cell in row[4:]:
if bits_cell.internal_value:
bits.append(bits_cell.internal_value)
if c.internal_value:
if c.internal_value == min(address):
min_address = True
address.remove(min(address))
print bits
return bits
You need to use a separate variable from
bitsto hold EVERY piece of data.bitsgets reset throughout your code, so I would recommend using something likeall_bitsand changebitstomin_addr_bits. Also, you need to make sure for EVERY row that isn’t blank, you append bits toall_bits. Example posted on request.