title: Python: get the names of specific file types in a given folder
body: <p>I have a folder which contains <code>n</code> <code>csv</code> files, and they are all named <code>event_1.csv</code>, <code>event_2.csv</code>, all the way up to <code>event_n.csv</code>. </p>
  
  <p>I want to be able to <code>raw_input</code> their folder path and then retrieve their names, <em>file extension excluded</em>.</p>
  
  <p>I tried to do it but I only get printed the folder path as many times as there are <code>csv</code> files in it. The filenames are never printed, instead, and they are what I want.</p>
  
  <p>This is the best I have come up with so far, but it does the wrong thing:</p>
  
  <pre><code>import os
  directoryPath=raw_input('Directory for csv files: ')
  for i,file in enumerate(os.listdir(directoryPath)):
      if file.endswith(".csv"):
          print os.path.basename(directoryPath)
  </code></pre>
  
  <p>where <code>directoryPath=C:\Users\MyName\Desktop\myfolder</code>, in which there are three files: <code>event_1.csv</code>, <code>event_2.csv</code>, <code>event_3.csv</code>.</p>
  
  <p>What I get is:</p>
  
  <pre><code>myfolder
  myfolder
  myfolder
  </code></pre>
  
  <p>What I want, instead, is:</p>
  
  <pre><code>event_1
  event_2
  event_3
  </code></pre>
  
  <p>PS: I expect to have as many as 100 files. Therefore I should be able to include situations like these, where the filename is longer:</p>
  
  <pre><code>event_10
  event_100
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>What can I add to make sure the files are read exactly in the same order as they are named? This means: first read <code>event_1.csv</code>, then <code>event_2.csv</code>, and so forth until I reach <code>event_100.csv</code>. Thanks!</p>