title: Find min value in a CSV and print every row that includes it in Python
body: <p>Thanks so much in advance for any help. I'm trying to write a script that will go through a folder of csv files, find the minimum value in the second column and print every row that contains it. The csv files the script looks through looks like this: </p>
  
  <pre><code>TPN,12010,on this date,25,0.00005047619239909304377497309619
  TPN,12011,on this date,23,0.00003797836224092152019127884704
  TPN,12012,on this date,78,0.0001130474103447076420049393022
  TPN,12020,on this date,27,0.00005671375308512314236202279053
  TPN,12021,on this date,60,0.00009856619048244864701475864425
  </code></pre>
  
  <p>The script looks like this: </p>
  
  <pre><code>import csv
  import os
  
  folder = '/Users/Documents/Senior/Thesis/Python/TextAnalysis/datedmatchedngrams2/'
  
  identity = []
  for filename in os.listdir (folder):
      with open(filename, 'rb') as inf:
          incsv = csv.reader(inf)
          column = 1               
          datatype = int
          data = (datatype(row[column]) for row in incsv)   
          least_value = min(data)
          print least_value
          for row in incsv:
              if least_value in column[1]:
                  identity.append(row)
              else:
                  print "No match"
          print identity
  </code></pre>
  
  <p>The error I get is: </p>
  
  <pre><code>  File "findfirsttrigram.py", line 12, in &lt;module&gt;
      identity.append("a")
  NameError: name 'identity' is not defined
  </code></pre>
  
  <p>I also tried doing it like this:</p>
  
  <pre><code>import csv
  import os
  
  folder = '/Users/Documents/Senior/Thesis/Python/TextAnalysis/datedmatchedngrams2/'
  
  for filename in os.listdir (folder):
      with open(filename, 'rb') as inf:
          incsv = csv.reader(inf)
          column = 1               
          datatype = int
          data = (datatype(row[column]) for row in incsv)   
          least_value = min(data)
          print least_value
          for row in incsv:
              if least_value in row:
                  print row
              else:
                  print "No match"
  </code></pre>
  
  <p>But that didn't work either. It did not give me an error but it also did not print "No match" so I have no idea where to start. Please help!! </p>