title: Dictionary of Lists to CSV in Python
body: <p>I currently have a dictionary who values are lists.</p>
  
  <p>Example: <code>{1: [12, 13, 14, 15], 2: [12, 13, 14, 15], 3: [12, 13, 14, 15]}</code> and so on.</p>
  
  <p>I have 20000 keys, and each list contains 80 values.</p>
  
  <p>I am trying to output this into a CSV file, but have had no luck using Dictwriter.  Here is part of my code:</p>
  
  <pre><code>for i in range(0, 3):
  
      filetxt = "\\Level_3\\" + nonsbar[i]
      filedata = list(csv.reader(open(filetxt,'rb'), delimiter='\t'));
  
      for j in range (1, len(filedata)):
          tempid = filedata[j][0]
          idind = tempid.index('|')
          geneid = tempid[idind+1:len(tempid)]
          genecount = filedata[j][1]
          nconn[geneid].append(genecount)
  
  
  for keys in nconn.keys():
      nconn[keys] = zip(nconn[keys])
  
  print "convert to table"
  nkeys = nconn.keys()
  filetxt = open('nonsmoke.csv', 'wb')
  nonsmoketab = csv.DictWriter(filetxt, nkeys,delimiter=',')
  nonsmoketab.writeheader()
  nonsmoketab.writerow(nconn)
  </code></pre>
  
  <p>I get an ouput like this:</p>
  
  <pre><code>114787  114786  
  [('161.00',), ('985.00',), ('68.00',)]  [('9.00',), ('19.00',), ('2.00',)]
  </code></pre>
  
  <p>I instead want this:</p>
  
  <pre><code>114787 114786   
  161     9
  985     19
  68      2
  </code></pre>