I have list of tuples which I am trying to figure out how to create a csv file with the Keys as column headers and value as column values.

Below is sample list of tuples:

```
[('d_conversion_rate', 1), ('prev_2wk_visit_count', 0.0), ('sku_id', '100088-01'), ('prev_1wk_uniq_purch_cnt', 0.0)]
[('d_conversion_rate', 0), ('prev_2wk_visit_count', 6.0), ('sku_id', '100088-02'), ('prev_1wk_uniq_purch_cnt', 0.0)] 
[('d_conversion_rate', 5), ('prev_2wk_visit_count', 7.0), ('sku_id', '100088-03'), ('prev_1wk_uniq_purch_cnt', 0.0)]

```

The expected csv file should have:

```
converstion_rate,  sku_id, prev_1wk_uniq_purch_cnt
1,                  100088-02, 0.0
0,                  100088-03, 6.0
5,                  100088-04, 7.0

```

This is the code which I wrote:

```
import os
import sys
import csv
import string
import random

def import_data_to_csv(dict_d):
    with open('C:/Reports/SI_Reconciliation_Reporting/2015/output/2015-04-19/test_dump.csv', 'w') as outfile:
        fp = csv.DictWriter(outfile, dict_d[0].keys())
        fp.writeheader()
        fp.writerows(dict_d)

for row in sku_weekL:
                #print row.items()
                for key, value in row.items():
                    sku_weekTemp.append((key, value))
                print sku_weekTemp

            #print sku_weekL
            #print sku_weekL
            #print dir(sku_weekL)
            import_data_to_csv(sku_weekTemp)

```

But running the script I get an error that the tuple object has no attribute keys.

Any ideas how to solve this?