title: How to transpose table with different number of column using Python?
body: <p>I need help in transposing these example from row to column. I know I can use Microsoft Excel to do this but since I will be working with bigger file ( > 1 million row), I want to know if there is a way of doing it using python.</p>
  
  <p>input.csv</p>
  
  <pre><code>-0.02 | -120.38 |         |
  -0.01 | -120.38 |  -120.1 |
  -0.02 | -120.4  |         |
  -0.01 | -70.45  |         |
  0     |  10.34  |   3.4   | 3.4
  0.1   |  20.21  |   90.45 |
  0.2   |  90.45  |   110.3 |
  </code></pre>
  
  <p>What I'm hoping for is to get this result</p>
  
  <p>output.csv</p>
  
  <pre><code>-0.02   |   -0.01   | -0.02  |  -0.01  |    0     | 0.1   | 0.2
  -120.38 |   -120.38 | -120.4 |  -70.45 |    10.34 | 20.21 | 90.45
          |   -120.1  |        |         |    3.4   | 90.45 | 110.3
          |           |        |         |    3.4   |       |
  </code></pre>
  
  <p>But what I get is this result </p>
  
  <pre><code>-0.02   |   -0.01   | -0.02  |  -0.01  |    0     | 0.1   | 0.2
  -120.38 |   -120.38 | -120.4 |  -70.45 |    10.34 | 20.21 | 90.45
  </code></pre>
  
  <p>It only print out the first two row.</p>
  
  <p>I am using this script to transpose the table :</p>
  
  <p>transpose.py</p>
  
  <pre><code>import csv
  
  data = zip(*csv.reader(open("input.csv", "rb")))
  csv.writer(open("output.csv", "wb")).writerows(data)
  </code></pre>
  
  <p>Thank you for your help.</p>