title: How to delete a row in csv file based on multiple conditions?
body: <p>I want to read a CSV file and delete a row in that CSV file based on three conditions, <strong>type</strong>, <strong>srcaddr</strong>, <strong>dstaddr</strong>.</p>
  
  <p>So for example, if i enter something like <strong>first</strong> condition is <strong>'icmp'</strong>, <strong>second</strong> condition is <strong>'10.0.0.1'</strong>, <strong>third</strong> condition is <strong>'10.0.0.2'</strong>, it will only delete that certain row.</p>
  
  <p>I have tried using this code but it only allows me to delete based on one condition only, how can I modify it to allow it to delete based on <strong>multiple conditions</strong>?</p>
  
  <pre><code>#code that I used to delete a row in CSV file based on only one condition.
  
  import csv
  import sys
  
  
  with open('firewall-policies-test.csv', "rb") as f:
      data = list(csv.reader(f))
  
  with open('firewall-policies-test.csv', "wb") as f:
      writer = csv.writer(f)
      for row in data:
          if row[0] != 'icmp':
                writer.writerow(row)   
  
  
  
  
  
  
   #code for CSV File
   type,srcaddr,dstadrr
   icmp,10.0.0.1,10.0.0.2
   tcp,10.0.0.1,10.0.0.2
  </code></pre>
  
  <p>It always give me an error saying list index out of range when i am trying to use and &amp; or operators..</p>
  
  <pre><code>Traceback (most recent call last):
    File "deletecsv.py", line 11, in &lt;module&gt;
      if row[0] != "icmp" and row[1] != '10.0.0.1' and row[2] != '10.0.0.2':
  IndexError: list index out of range
  </code></pre>