title: Pythonic way to create a dict of Excel column values
body: <p>I have an Excel worksheet and I want to create a dict which has the cell values as a list with cell column being the key. Let say that spreadsheet has data that looks like,</p>
  
  <pre><code>A B C (columns)
  1 2 
  3 4
  5 f
  </code></pre>
  
  <p>I want a dict that looks like,</p>
  
  <pre><code>cbyc = {'A': [1,3,5]; 'B':[2,4,f]; 'C';[None, None, None]}
  </code></pre>
  
  <p>I am doing this with the following code</p>
  
  <pre><code>import openpyxl as oxl
  wb = oxl.load_workbook('myxlworkbook.xlsx')
  sheet = wb.get_sheet_by_name('Sheet1')
  allcells = sheet.get_cell_collection()
  
  cbyc = {}
  for c in allcells:
      if c.value is not None:
          if c.column not in cbyc.keys():
              cbyc[c.column] = [c.value]
          else:
              cbyc[c.column].append(c.value)
  </code></pre>
  
  <p>And this work,.. but I am sure there is a more efficient way to create this dict with the if.. else logic</p>
  
  <p>is there a better way? Maybe there is something in the openpyxl that can give such a list</p>