Write python dictionary to CSV columns: keys to first column, values to second

You could simply do in python 2.X :

with open('test.csv', 'wb') as f:
    writer = csv.writer(f)
    for row in myDict.iteritems():
        writer.writerow(row)

For python 3.X, change the for loop line to for row in myDict.items():


A slightly shorter version is to do:

rows = myDict.iteritems()

(Or .items() for Python 3.)

To get the ; separator, pass delimiter to csv.reader or csv.writer. In this case:

writer = csv.writer(f, delimiter=';')