title: How to print output to a csv file?
body: <p>I need help in writing code to print output to csv file. The code is posted below. Appreciate your help.</p>
  <pre><code>import csv
  
  result = {}
  
  with open('data.csv', 'rb') as csvfile:
      csvreader = csv.reader(csvfile, delimiter=',', quotechar='&quot;')
      for row in csvreader:
          if row[0] in result:
              result[row[0]].append(row[1])
          else:
              result[row[0]] = [row[1]]
  
  print(result)
  </code></pre>