SHARE
TWEET

Untitled

a guest Jun 20th, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bits = []
  2.  
  3. for row in ws.iter_rows(row_offset=4,column_offset=3):
  4.     #skip over empty rows
  5.     if row:
  6.         #current cell is in column C
  7.         cell = row[2]
  8.         try:
  9.             #find the lowest address in the excel sheet
  10.             if cell.internal_value == min(address):
  11.                 #somehow match up in column d
  12.                 for '''loop and search col D''':
  13.                     if str(row[3].internal_value).upper == ('CONTROL 1' or 'CON 1'):
  14.                         #add bits
  15.                         for cell in row[4:]:
  16.                             bits.append(cell.internal_value)    
  17.         #pass over cells that aren't a number, ie values that will never match an address
  18.         except ValueError:
  19.             pass
  20.         except TypeError:
  21.             pass
  22.      
  23. bits = []
  24. min_address = False
  25. for row in ws.iter_rows(row_offset=4,column_offset=3):
  26.     c = row[2]
  27.     d = row[3]
  28.     if not d.internal_value: #d will always have a value if the row isn't blank
  29.         if min_address:
  30.             break #bits is what you want it to be now
  31.         bits = [] #reset bits every time we hit a new row
  32.         continue #this will just skip to next row
  33.  
  34.     for bits_cell in row[4:]:
  35.         if bits_cell.internal_value:
  36.             bits.append(bits_cell.internal_value)
  37.     if c.internal_value:
  38.         if c.internal_value == min(address):
  39.             min_address = True #we set it to true, then kept going until blank row
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top