title: Why does my openpyxl WorkBook.active() give me a TypeError: Object is not callable?
body: <p>I am trying out openpyxl for the first time. I have an excel file, with two columns of data. Column 'A' has ID-numbers, while column 'C' has values. I am simply trying to extract them, as a plain key/value object.</p>
  
  <p>These are the pseudo steps I figure i need to implement</p>
  
  <ul>
  <li>Find the file by location, and create a workbook object</li>
  <li>Define a WorkSheet object. In my case, this is the default first page</li>
  <li>Iterate through the rows, as long as there are key values in column 'A'</li>
  <li>Add key and value from 'A' and 'C' into an object.</li>
  </ul>
  
  <p>The problem is that I can't get past step 2, creating a worksheet. The line <code>ws = wb.active()</code>seems like a completely standardized way of getting the default WorkSheet. I see it used in a lot of examples, and as of writing this, there are 93 questions on SO using the line. But in my case, it throws an error:</p>
  
  <pre><code>  File "C:\myworkspace\Myclass.py", line 18, in &lt;module&gt;
      ws = wb.active()
  TypeError: 'ReadOnlyWorksheet' object is not callable
  </code></pre>
  
  <p>I am quite new to Python, but I've run into similar errors before. I know that it is thrown for instance if I import a python module name, instead of the relevant class name. What exactly is happening here? Why is this seemingly standard method of retrieving a worksheet object, trying to instanciate a module instead of a class? Am I using it wrong?</p>
  
  <pre><code>file_url = 'C:/myfilepath.xlsx'
  key_column_index = 1
  value_column_index = 3
  row_start = 2
  
  request_map = {}
  
  wb = load_workbook(filename = file_url, use_iterators = True)
  ws = wb.active()
  
  row_counter = row_start
  
  while( ws.cell(row=row_counter, column=key_column_index).value ):
      key = ws.cell(row=row_counter, column=key_column_index).value
      value = ws.cell(row=row_counter, column=value_column_index).value
      request_map[key] = value
  
      row_counter += 1
  
  pprint(dict([(n, tuple(l.split(';'))) for n, l in enumerate(requests.split('\n'))]))
  </code></pre>
  
  <p><strong>Just to make this really really weird, I present you with this:</strong></p>
  
  <p>I wanted to reproduce my error in the simplest possible way, so I found the shortest example I could, and copied it into my workspace. With the exception of the file path, this is completely identical to Ryu_Hayabusa's answer to this question: <a href="https://stackoverflow.com/questions/7372716/parsing-excel-documents-with-python/32535915#32535915">parsing excel documents with python</a>. Now get this: It works, without any errors!</p>
  
  <pre><code>file_url = 'C:/myfilepath.xlsx'
  wb = load_workbook(file_url)
  ws = wb.active
  for row in ws.iter_rows():
     for cell in row:
       print cell.value
  </code></pre>
  
  <p>Of course, i suspected that the bold text in the line</p>
  
  <p>wb = load_workbook(<strong>filename =</strong> file_url <strong>, use_iterators = True</strong> ) </p>
  
  <p>was the problem, but no. Removing the bold marked text, to make it identical to the working example, still produced an error. The only difference is that now it says <code>Worksheet</code> instead of <code>ReadOnlyWorksheet</code> What in the big wide world is going on here???</p>