title: Read in all csv files from a directory using Python
body: <p>I hope this is not trivial but I am wondering the following:</p>
  
  <p>If I have a specific folder with <em>n</em> <code>csv</code> files, how could I iteratively read all of them, one at a time, and perform some calculations on their values?</p>
  
  <p>For a single file, for example, I do something like this and perform some calculations on the <code>x</code> array:</p>
  
  <pre><code>import csv
  import os
  
  directoryPath=raw_input('Directory path for native csv file: ') 
  csvfile = numpy.genfromtxt(directoryPath, delimiter=",")
  x=csvfile[:,2] #Creates the array that will undergo a set of calculations
  </code></pre>
  
  <p>I know that I can check how many <code>csv</code> files there are in a given folder (check <a href="https://stackoverflow.com/questions/9234560/find-all-csv-files-in-a-directory-using-python">here</a>):</p>
  
  <pre><code>import glob
  for files in glob.glob("*.csv"):
      print files 
  </code></pre>
  
  <p>But I failed to figure out how to possibly nest the <code>numpy.genfromtxt()</code> function in a for loop, so that I read in all the csv files of a directory that it is up to me to specify. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The folder I have only has <code>jpg</code> and <code>csv</code> files. The latter are named <code>eventX.csv</code>, where <em>X</em> ranges from 1 to 50. The <code>for</code> loop I am referring to should therefore consider the file names the way they are.</p>