title: to_csv command in For loop not working as expected
body: <p>I have 11 files in my directory that starts with 'case-export-'. For each of these files, I want to extract only 5 columns as indicated in the 'initial_columns' variable, save the results to a dataframe called 'whole_file', and write the 'whole_file' dataframe to a CSV. Because I have 11 files that matches 'case-export-' in my directory, I should have 11 CSVs generated by my script. </p>
  
  <p>When I run the scripts below, I only got 1 CSV generated, and that CSV has data from the most recent file read by the For loop. </p>
  
  <pre><code>date = dt.datetime.today().strftime("%m_%d_%Y")
  directory = '/Users/myname/Downloads/'
  initial_columns = ['Case #','Case Subject','Created At','Labels','Body'] 
  
  for file in (glob.glob(directory + 'case-export-*')):
      whole_file=pd.read_csv(file, usecols = initial_columns, encoding='ISO-8859-1', index_col=None, low_memory=False).replace(np.nan, 'blank', regex=True)   
      whole_file.to_csv(directory + 'case_export_trimmed_' + date + '_' + str(now.hour) + '_' + str(now.minute) + '_' + str(now.second) + '.csv')
  </code></pre>
  
  <p>I know how to get around this by adding an empty dataframe and then concatenating each 'whole_file' to the dataframe as it goes through the loop. I tried that and it worked perfectly. However, I am trying to understand why my original script that I shown above did not work as expected and why it only produced 1 CSV instead of 11. Please advise.</p>