Use the csv module and list comprehension:
import csv
dict1 = {0: 33.422, 1: 39.2308, 2: 30.132}
dict2 = {0: 42.2422, 1: 43.342, 2: 42.424}
dict3 = {0: 13.422, 1: 9.2308, 2: 20.132}
dict4 = {0: 32.2422, 1: 23.342, 2: 32.424}
dicts = dict1, dict2, dict3, dict4
with open('my_data.csv', 'wb') as ofile:
writer = csv.writer(ofile, delimiter='\t')
writer.writerow(['ID', 'dict1', 'dict2', 'dict3', 'dict4'])
for key in dict1.iterkeys():
writer.writerow([key] + [d[key] for d in dicts])
Note that dictionaries is unordered by default, so if you want the keys in ascending order, you have to sort the keys:
for key in sorted(dict1.iterkeys(), key=lambda x: int(x)):
writer.writerow([key] + [d[key] for d in dicts])
If you need to handle situations where you can't be sure that all dicts have the same keys, you'll need to change some small stuff:
with open('my_data.csv', 'wb') as ofile:
writer = csv.writer(ofile, delimiter='\t')
writer.writerow(['ID', 'dict1', 'dict2', 'dict3', 'dict4'])
keys = set(d.keys() for d in dicts)
for key in keys:
writer.writerow([key] + [d.get(key, None) for d in dicts])