title: How to write a Dictionary to Excel in Python
body: <p>I have the following dictionary in python that represents a From - To Distance Matrix.</p>
  
  <pre><code>graph = {'A':{'A':0,'B':6,'C':INF,'D':6,'E':7},
  
           'B':{'A':INF,'B':0,'C':5,'D':INF,'E':INF},
  
           'C':{'A':INF,'B':INF,'C':0,'D':9,'E':3},
  
           'D':{'A':INF,'B':INF,'C':9,'D':0,'E':7},
  
           'E':{'A':INF,'B':4,'C':INF,'D':INF,'E':0}
  
           }
  </code></pre>
  
  <p>Is it possible to output this matrix into excel or to a csv file so that it has the following format? I have looked into using csv.writer and csv.DictWriter but can not produce the desired output. </p>
  
  <p><a href="https://i.stack.imgur.com/jlgu7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jlgu7.png" alt="enter image description here"></a></p>