title: Need to write multiple csv files to new folder
body: <p>I haven't been able to find any information on this topic here, and would really appreciate your help! I'm pretty new to python, but here's what I have.</p>
  
  <p>I have multiple file in a folder, and want to read them, transpose them, and then rewrite them into a new folder. I think I have everything going, but can't figure out how to rewrite everything.</p>
  
  <p>here is my code:</p>
  
  <pre><code>path = 'C:\Users\Christopher\Documents\Clemson\Pleurodires\stability data\Es03\fixed\processed'
  filenames = glob.glob(path + "/*.csv")
  for filename in filenames:
      dfs = (pd.read_csv(filename))
      df = dfs.transpose()
      df.to_csv('transposed\' + 'Tr_' + filename)
  </code></pre>
  
  <p>the last line (i hope) should put all the new files in the folder called 'transposed', adding a Tr_ in front of the name which was loaded initially (ie if the file name was 'hello' it would now be 'Tr_hello' inside of the folder transposed). </p>
  
  <p>What is happening when I run the code above, is that it says it works, but then the files don't exist anywhere in my computer. I've tried playing around with a variety of different ways to get the df.to_csv to work and this is the closest I've gotten</p>
  
  <p><strong><em>Edit</em></strong></p>
  
  <p>Thanks for everyone's help, I ended up combining a mix of Nanashi's and EdChun's code to get this, which works: (the final files are in the correct folder, and are called Tr_filename)</p>
  
  <pre><code>path = r'C:\Users\Christopher\Documents\Clemson\Pleurodires\stability data\Es03\fixed\processed'
  filenames = glob.glob(path + "/*.csv")
  for filename in filenames:
      short = os.path.split(filename)
      newfilename = 'Tr_%s' % short[-1]
      #print newfilename
      dfs = (pd.read_csv(filename))
      df = dfs.transpose()
      df.to_csv(os.path.join('transposed', newfilename))
  </code></pre>