title: How do I add specifically found (OCR) text into a list and write it to an excel file? [pytesseract]
body: <p>I want to extract certain information from many PNG/JPEG files through pytesseract and write them into an excel file if possible.</p>
  
  <p>I've figured out how to extract the text from the pictures but what I haven't figured out is:</p>
  
  <p>1) How do I extract specific information instead of a whole blob of words? For example, I want the account numbers and reference numbers from each photo, nothing else. </p>
  
  <p>2) How do I write these account numbers and reference numbers into an external file such as excel? </p>
  
  <p>I'll attach what I've got so far below:</p>
  
  <p>I've heard that using pandas dataframes was a good way to append data into columns for Excel but I'm not sure if I can do that for a task like this.</p>
  
  <pre><code>from PIL import Image
  import pytesseract
  import pandas as pd
  
  pytesseract.pytesseract.tesseract_cmd = "C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"
  
  im = Image.open("C:/Users/user1/desktop/scripts/ocr/example bills/pic.jpg")
  
  
  content = pd.DataFrame()
  text = pytesseract.image_to_string(im, lang= 'eng')
  temp = pd.DataFrame({'Words':[text]})
  content.append(temp)
  
  content.head()
  
  print(text)
  writer = pd.ExcelWriter('wordstest.xlsx')
  content.to_excel(writer,'Sheet1')
  writer.save()
  
  </code></pre>
  
  <p>Expected Results:</p>
  
  <p>An excel file with two columns, account number and reference number.</p>
  
  <p>Actual Results:</p>
  
  <p>An excel file with no data. </p>