title: Writing all the values of a dictionary in columns
body: <p>I have a dictionary in which each key has list as a value. The thing is, number of elements of each list is different for each key. Instead of writing as Rows using csv, i am writing them in columns. Lets say the format of the dictionary is as below:  </p>
  
  <pre><code>myDict = {'cli1':['9','1'], 'cli2':['6','8','4'], 'cli3':['7']}  
  </code></pre>
  
  <p>I wanted to print in a .csv file in the following fashion:  </p>
  
  <pre><code>cli1    cli2    cli3
  9       6       7  
  1       8
          4   
  </code></pre>
  
  <p>I wrote the following program to accomplish the task:  </p>
  
  <pre><code>with open('PduDictOut.csv','wb') as file:
      writer = csv.writer(file, delimiter='\t')
      writer.writerow(myDict.keys())
      for row in zip(*myDict.values()):
              writer.writerow(list(row))
  file.close()  
  </code></pre>
  
  <p>But this program is giving me the below output:  </p>
  
  <pre><code> cli1    cli2    cli3 
   9       6       7    
  </code></pre>
  
  <p>My program is taking the key with minimum number of items in its list and its giving me the same number of elements for all the keys. How can i change the program to generate the output like i wanted. Thanks in advance. Help is very much appreciated. BTW i am using Python 2.6.</p>