title: Python 2.7 Match Exact String in the Row of a CSV File
body: <p>I have a csv file containing strings in a specific column and other values in the others. I have also a list of strings.
  Cycling over lines, I'd like to check if one of the strings in the list is exactly contained in the line of the csv file.
  If yes, this line has to be written in a new csv file.</p>
  
  <p>The csv file is a list of rows like:</p>
  
  <pre><code>22/06/2017 04:00:32 | string1 | value1   
  22/06/2017 04:00:32 | string11 | value2    
  22/06/2017 04:00:32 | string2 | value3   
  22/06/2017 04:00:32 | string3 | value4
  </code></pre>
  
  <p>I wrote this code, it works fine but it doesn't consider the "exact" matching of strings.</p>
  
  <pre><code>import os, csv
  
  def filter_csv(folderpath):
  
       list1 = [
       ('name1',1,'string1','value1'),
       ('name2',2,'string2','value2'),
       ('name3',3,'string3','value3'),
       ('name4',4,'string4','value4'),
       ...
       ]
  
       def column(matrix, i):
           return [row[i] for row in matrix]
  
       col = column(list1,2)
  
       for file in os.listdir("%s" % folderpath):
           if file.endswith(".csv"):
               new_file = 'new_'+file
               filepath = os.path.join("%s" % folderpath, file)
               new_filepath = os.path.join("%s" % folderpath, new_file)
  
               with open('%s' % filepath) as csvfile:
                   lines = csvfile.readlines()
  
               with open('%s' % new_filepath, 'wb') as csvfile2:
                   for line in lines:
                       for namevar in col:
                           if namevar in line:
                               csvfile2.write(line)
  
       return
  </code></pre>
  
  <p>How can I add the exact matching of strings for a column of the csv file?</p>