I've been trying to save my dictionary to a csv file. So I want it to look something like this: 

```
Subject                           value1   concussion
network3_UCA_0073_01_(0, 1)        0.57     no 
network3_UCA_0073_02_(0, 1)        0.64     no 
network3_UCA_0073_03_(0, 1)        0.59     no 
network3_UCA_0075_01_(0, 1)        0.69     no

```

The dictionary looks like this: 

```
{}
{}
{}
{}
{}
{}
{'network3_UCA_0073_01_(0, 1)': [(0.57, 'no')]}
{'network3_UCA_0073_02_(0, 1)': [(0.64, 'no')]}
{'network3_UCA_0073_03_(0, 1)': [(0.59, 'no')]}
{}
{}
{'network3_UCA_0075_01_(0, 1)': [(0.69, 'no')]}
{'network3_UCA_0075_02_(0, 1)': [(0.62, 'no')]}
{'network3_UCA_0075_03_(0, 1)': [(0.57, 'no')]}
{'network3_UCA_0076_01_(0, 1)': [(0.38, 'no')]}
{'network3_UCA_0076_02_(0, 1)': [(0.60, 'no')]}
{'network3_UCA_0076_03_(0, 1)': [(0.68, 'no')]}
{'network3_UCA_0077_01_(0, 1)': [(0.64, 'no')]}
{'network3_UCA_0077_02_(0, 1)': [(0.58, 'no')]}
{'network3_UCA_0077_03_(0, 1)': [(0.48, 'no')]}

```

The code I've been using to achieve this looks like the following (but unfortunately it hasn't been working): 

```
with open(dirforR , 'a') as f:                                         
    writer = csv.writer(f)      
    writer.writerow(['Subject', 'value1', 'concussion'])                             

    for row in sorted_combined:                                        
        #print row[0]                                                   

        l = [row[0]]                                                   
        l.append(row[1][0])                                            
        l.append(row[1][1])                                            
        writer.writerow(l)                                             

```

I'm not sure if its because the dictionary's key's are separated by \n , but any help would be greatly appreciated. I've tried to figure it out with no hope. 

Thanks for your help. I hope to hear back soon . 
\*\*\*\*\*\*\*\*\*EDIT\*\*\*\*\*\*\*\*\*\*\*

I realized that this is no ordinary dictionary, I actually have it set to: 

```
sorted_combined = defaultdict(list)

```

the reason for this is because I was merging two dictionaries together and this was the only way I was able to go about it..
Now I'm not quite sure how to move my dictionary list to a csv file. 

Sorry this got a little messy.

\*\*\*EDIT2 \*\*\*this is the code that was used to make my defaultdict list called: network\_combined

```
network3 = defaultdict(list)    
combined_MDD = {key : (MDD_network3[key], MDD_network3_yesno[key]) for key 
in MDD_network3}                                                                   
combined_HC = {key : (HC_network3[key], HC_network3_yesno[key]) for key in HC_network3}
for k, v in chain(combined_MDD.items(), combined_HC.items()):             
     network3[k].append(v)                                                
sorted_combined = {k:v for k,v in network3.items() if k.endswith('(0, 1)')}                                                      

```