import csv
csvout = csv.writer(open('mydata.csv', 'wb'))
csvout.writerow(('Country', 'Year'))
for coutry, year in my_data_iterable():
    csvout.writerow((country, year))
How to write data to an excel file?