title: Openpyxl, append key value to column if key matched with cell?
body: <p>I have an excel file containing:</p>
  
  <p>A1 = Company Name
  B1 = Mobile</p>
  
  <p>etc</p>
  
  <p>I generated a dictionary out of some data having the colmumn headers as keys, comparing the cells to keys to check if it matches. On match, I want to compare the cells of that column against the value of matched key. If value is not present <code>append</code> to the column.</p>
  
  <pre><code>for key in dictionary_test.keys():
      os.chdir("C:\Python34")
      wb = load_workbook("Trying web.xlsx")
      ws = wb.active
      for row in ws.iter_rows():
          for cell in row:
              if key == cell.value:
  
          ws.append(dictionary_test)
          wb.save("Trying web.xlsx")
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):
     File "", line 8, in 
    File "C:\Python34\lib\site-packages\openpyxl\worksheet\worksheet.py", line 692, in append
       col_idx = column_index_from_string(col_idx)
     File "C:\Python34\lib\site-packages\openpyxl\utils__init__.py", line 112, in >column_index_from_string
       raise ValueError("{0} is not a valid column name".format(str_col))
    ValueError: Contact Person is not a valid column name</p>
  </blockquote>
  
  <p>How would I go about correcting this?</p>
  
  <p>Structure of the excel file:</p>
  
  <p>A1 = Company</p>
  
  <p>B1 = Mobile</p>
  
  <p>C1 = Phone  </p>
  
  <p>D1 = Contact Person</p>
  
  <p>E1 = Call Us</p>
  
  <p>F1 = Address</p>
  
  <p>Currently there is nothing in the cells below them.</p>