title: Sort out columns of multiple csv files at once in Python
body: <p>really appreciate your help.</p>
  <p>I have around 200 csv files with same header.
  eg of headers are <code>x , y, z, time, id, type</code></p>
  <p>I would like to sort out <code>time</code> colums of all csv files and save them again.</p>
  <p>This is so far I have tried. But it doesn't work.</p>
  <p>Could you please help me ??</p>
  <p>Thank you</p>
  <pre><code>
  import csv
  import operator
  import glob
  import pandas as pd
  
  data = dict() # filename : lists
  
  path=&quot;./*.csv&quot;
  files=glob.glob(path)
  
  for filename in files:
      # process each file
      with open(filename, 'r') as f:
          # read file to a list of lists
          lists = [row for row in csv.reader(f, delimiter=',')]
          # sort and save into a dict
          sorted_df = lists.sort_values(by=[&quot;time&quot;], ascending=True)
          sorted_df.to_csv('%.csv', index=False)
  </code></pre>