title: Python - excel - count number of words in cell, using two csv dictionaries
body: <p>I have a Python code which counted occurrences of words on text (.txt) files:</p>
  
  <pre><code>find_words = re.compile(r'(?:(?&lt;=[^\w./-])|(?&lt;=^))[A-Za-z]+(?:-[A-Za-z]+)*(?=\W|$)').findall
  wanted1 = set(find_words(open('word_list_1.csv').read().lower()))
  wanted2 = set(find_words(open('word_list_2.csv').read().lower()))
  negators = set(find_words(open('negators.csv').read().lower()))
  ignore = set(find_words(open('Ignore words.csv').read().lower()))
  </code></pre>
  
  <p>then I would do the following to process the text files:</p>
  
  <pre><code>with open(csvfile, "wb") as output:
   writer = csv.writer(output)
   for f in glob.glob("*.txt"):
              print "Processing file number : ", i, " out of :", len(glob.glob("*.txt"))
              i=i+1
              with open(f) as inputfile:
                  wordNumber=0
                  for line in inputfile:
                   if find_words(line.lower()) != []:
                      lineWords=find_words(line.lower())
  </code></pre>
  
  <p>So, the question is, how do I do that for an excel file instead of .txt files? I tried to do the following:</p>
  
  <pre><code>for i in range(0, rows):
    for j in range(0,cols):
      write_sheet1.write(i,j,sheet.cell_value(i,j))
    if sheet.cell_value(i,4)!=0:
      for line in sheet.cell_value(i,4):
   print "Line is : ", line
   if find_words(line.lower()) != []:
      lineWords=find_words(line.lower())
  </code></pre>
  
  <p>but it is not working, it returns only one character, not the whole line and/or words...</p>
  
  <p>So how can I make it work for excel cells instead of text files?</p>