title: Word frequency counter for excel using Python
body: <p>I have the following python code to count the number of occurrences in an excel file. This is written to work even if a cell contains a sentence. However, for some reasons it's not working and I get TypeError: argument of type 'Cell' is not iterable.</p>
  
  <p>Can someone help.</p>
  
  <pre><code>import xlrd
  import os
  for filename in os.listdir("D:\MyData\MyPythonCodes\Excel reading\search using xlrd"):
  if filename.find('xlsx') != -1:
      print(filename)        
      workbook = xlrd.open_workbook(filename)
      sheet = workbook.sheet_by_name("Sheet1")
      values = []
      for row in range(sheet.nrows):
          for col in range(sheet.ncols):
              if " " in sheet.cell(row,col):
                  values.append(str(sheet.cell(row,col).value.split(" ")))
              else:
                  values.append(str(sheet.cell(row,col)))
  print(values.count("abcd")) times")
  </code></pre>