title: Creating dictionary from excel workbook in python using sheet names as key
body: <p>I have multiple excels sheets in workbook with names like sheet1, sheet2 , sheet3 and I am converting the data in each sheet into a dictionary using headers as key. But now I want to create a nested dictionary where i add sheet name as key to each of the above dictionaries. My table has multiple sheets of this form:
  Sheet1</p>
  
  <pre><code>IP Address     prof     type
  xx.xx.xx       abc      xyz
  xx.xx.xx       efg      ijk
  </code></pre>
  
  <p>Sheet2</p>
  
  <pre><code>IP Address     prof     type
  xx.xx.xx       abc      xyz
  xx.xx.xx       efg      ijk
  </code></pre>
  
  <p>Now I attempted like this:</p>
  
  <pre><code>from xlrd import open_workbook
  
  book = open_workbook('workbook.xls')
  sheet = book.sheet_by_index(0)
  sheet_names = book.sheet_names()
  
  # reading header values 
  keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)]
  
  dict_list = []
  for row_index in range(1, sheet.nrows):
      d = {keys[col_index]: sheet.cell(row_index, col_index).value
           for col_index in range(sheet.ncols)}
      dict_list.append(d)
  
  print (dict_list)
  </code></pre>
  
  <p>Which prints this : </p>
  
  <pre><code>[{'IP Address': 'xx.xx.xx', 'prof': 'abc', 'type': 'xyz'}, {'IP Address': 
  'xx.xx.xx', 'prof': 'efg', 'type': 'ijk'}]
  
  what I need is :
      [{'Sheet1':{'IP Address': 'xx.xx.xx', 'prof': 'abc', 'type': 'xyz'}, {'IP 
      Address': 'xx.xx.xx', 'prof': 'efg', 'type': 'ijk'}},
      {'Sheet2':{'IP Address': 'xx.xx.xx', 'prof': 'abc', 'type': 'xyz'}, {'IP 
        Address': 'xx.xx.xx', 'prof': 'efg', 'type': 'ijk'}},
         ]
  </code></pre>
  
  <p>I have problems adding the sheet name as key for multiple sheets in workbook. </p>
  
  <p>Any help will be appreciated.</p>