if statement - Python: Setting conditions within if-elif-else block -


i have following code snippet:

for row in lst:     if 'type' in row[0]:         col in range(len(row)):             #do     elif (not 'type' or '') in row[0]:         col in range(len(row)):             #do row_count +=1 

for second part of elif (not 'type' or '') how not increase row_count counter if true row[0] = '' increase when row[0] != type met ? coudnt set counter condition withion if-else block im scanning row row in lst row read csv reader in python.

perhaps i'm complicating myself much? advices plz.

[edit] - here's actual code, im using xlwt module write worksheets.

for row in spamreader:     if 'type' in row[0]:         col in range(len(row)):             ws.write(0,col,convert(row[col]),style)      elif (not 'type' or '') in row[0]:         col in range(len(row)):             ws.write(row_count,col,convert(row[col]),style)     row_count +=1 

more details: have csv file im scanning row row. whichever row 1st value 'type', im writing in xls worksheet becomes top row. else, continues copy row row. but, when row's 1st column empty, i.e. '', suppose pass/neglect it.

how this:

for row in spamreader:     if row[0] == '':         continue      if 'type' in row[0]:         row_count = 0         ... start new worksheet ...      col in range(len(row)):         ws.write(row_count,col,convert(row[col]),style)  

Comments