title: Converting csv rows to columns with Python
body: <p>Could you help me, please ?</p>
  
  <p>I need to convert :</p>
  
  <ul>
  <li>one row with multiple columns from several files</li>
  </ul>
  
  <p>TO </p>
  
  <ul>
  <li>one file</li>
  </ul>
  
  <p>WHERE </p>
  
  <ul>
  <li>the number of columns equals to the number of files</li>
  <li>and the number of rows equals to the number of columns from input files.</li>
  </ul>
  
  <p><strong>Input Files</strong></p>
  
  <p>File 1 :
  32676;;90;5;22;...;4</p>
  
  <p>File 2 :
  255;35;88;17;;...;151</p>
  
  <p>File 3 :
  551;86;442;;78;...;20</p>
  
  <p><strong>Output file</strong></p>
  
  <p>32676;255;551</p>
  
  <p>;35;86</p>
  
  <p>90;88;442</p>
  
  <p>5;17;</p>
  
  <p>22;;78</p>
  
  <p>...;...;...</p>
  
  <p>4;151;20</p>
  
  <p>Thanks a lot for your help !</p>
  
  <pre><code>My code :
  
  path = 'D:\Users\mim\Desktop\SI\Test_cvs'
  pathglobalcsv = 'D:\Users\mim\Desktop\SI'
  
  #create a new file
  globalfile = open(os.path.join(pathglobalcsv, 'global.csv'), 'w+')
  
  #write filenames like column names
  files = os.listdir(path)
  globalfile.write(';'.join(files))
  globalfile.write('\n')
  
  #get all values
  for filename in glob.glob(os.path.join(path, '*.csv')):
      csvfile = open(filename, 'r')
      textcsv = csv.reader(csvfile, delimiter=';')
      globalfile.write(zip(*textcsv))
  
  I have an error : 
  
  Traceback (most recent call last):
    File "C:\Users\mim\eclipse-workspace\test\csv_global.py", line 86, in &lt;module&gt;
      globalfile.write(zip(*textcsv))
  TypeError: expected a string or other character buffer object
  </code></pre>