title: Extract file name from read_csv - Python
body: <p>I have a script that current reads raw data from a .csv file and performs some pandas data analysis against the data.  Currently the .csv file is hardcoded and is read in like this:</p>
  
  <pre><code>data = pd.read_csv('test.csv',sep="|", names=col)
  </code></pre>
  
  <p>I want to change 2 things:</p>
  
  <ol>
  <li><p>I want to turn this into a loop so it loops through a directory of .csv files and executes the pandas analysis below each one in the script.</p></li>
  <li><p>I want to take each .csv file and strip the '.csv' and store that in a another list variable, let's call it 'new_table_list'.  </p></li>
  </ol>
  
  <p>I think I need something like below, at least for the 1st point(though I know this isn't completely correct). I am not sure how to address the 2nd point</p>
  
  <p>Any help is appreciated</p>
  
  <pre><code>import os 
  
  path = '\test\test\csvfiles'
  table_list = []
  
  for filename in os.listdir(path):
      if filename.endswith('.csv'):
          table_list.append(file)
  data = pd.read_csv(table_list,sep="|", names=col)
  </code></pre>