0

I have written a python generator expression as follows:

with open(input_file) as open_file:
print open_file
reader = csv.reader(open_file, delimiter="\t")
reader = (row for row in reader 
          if row[12] != "..." or
          row[13] != "-" or
          row[18] != "-" or
          not re.search(r'p.', row[18]))

If like to exclude any rows where the conditions are True, so the ORs definitely apply and there is no nesting here. I have no syntactical errors but when I print row[18] I am returned "-" so something is wrong here. All of my ifs are actually being ignored. Any help is much appreciated.

Adam Mark
  • 1
  • 1
  • Do you mean to use `and` here instead of `or`? – Brandon Humpert Oct 22 '14 at 18:34
  • multiple conditions chained together with `or` will evaluate to True if _any_ of them are true. So if `row[12]` equals anything but "...", your expression will be True, and it won't even bother looking at row[18]. – Kevin Oct 22 '14 at 18:34
  • No, if any of the conditions are True, I'd like to skip the entire row. This question was marked duplicate but the other link was no help. – Adam Mark Oct 22 '14 at 18:38

0 Answers0