title: How to search an xlsx file for a specific string using Python (and perhaps openpyxl)
body: <p>How can I search an xlsx file for a specific string variable? Example:</p>
  
  <p><strong>ORIGINAL TEXT FILE:</strong>                          </p>
  
  <pre><code>one - a b c                                         
  two - a b c                                      
  three - a b c                                     
  four - a b c                                           
  five - a b c                                           
  </code></pre>
  
  <p><strong>XLSX FILE:</strong>                                             </p>
  
  <pre><code>two                                                    
  three                                                  
  five
  </code></pre>
  
  <p><strong>OUTPUT CSV FILE:</strong></p>
  
  <p>The following in two columns:</p>
  
  <pre><code>two a 
  two b 
  two c 
  three a 
  three b 
  three c 
  five a 
  five b
  five c 
  </code></pre>
  
  <p>In short, I am going line-by-line in my original text file, selecting a specific string such as 'one', 'two', or 'three' and I am looking to see if that string exists in the xlsx file (I realize that it might be more ideal to search the other way around, but I'm trying to keep things very simple as this is only a section of my code). Ultimately I then identify the a,b,c paramaters and send it all out to a csv file.</p>
  
  <p>-- I already imported os, csv, re, openpyxl, load_workbook (from openpyxl), sys, and set default encoding to utf-8 </p>
  
  <pre><code>with open("OriginalTextFile.txt", 'r') as SearchList:
      for line in SearchList:
          line_text = str(line)
          try:
              test_query = re.search('start (.+?) end', line_text).group(1)
              print test_query # confirms that I AM getting the correct test_query
              if str(test_query) in load_workbook('Subset.xlsx', read_only=True):
                  print 'FOUND IT IN SUBSET!'
  
                   ----- Continues -----
  </code></pre>
  
  <p>My question lies within line 7 specifically; how can I identify the existence of a specific string (eg. "one") in my subset.xlsx file? Is this line correct and I'm just missing something simple? Any additional suggestions, links, tutorials, documentations are welcome!</p>
  
  <p>Thank you very much, in advance!</p>