The purpose of the program is to take a picture of handwritten inquiry card and submit the information written on to an online form.
Code:
import pytesseract
from PIL import Image
# Open the image file using PIL library
image = Image.open('inquirycard.jpg')
# Extract text from the image using pytesseract
text = pytesseract.image_to_string(image)
# Save the extracted text to a file
with open('extracted_text.txt', 'w') as file:
file.write(text)
import pandas as pd
# Read the extracted text file using Pandas
df = pd.read_csv('extracted_text.txt', delimiter='\t', header=None)
# Save the text to a CSV file
df.to_csv('extracted_text.csv', index=False)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Open the online form using Selenium
driver = webdriver.Chrome()
driver.get('https://your-online-form-url.com')
# Find the input element on the online form using its ID
input_element = driver.find_element_by_id('input-element-id')
# Read the text from the spreadsheet using Pandas
df = pd.read_csv('extracted_text.csv')
text = df.to_string(index=False, header=False)
# Enter the text into the input element and submit the form
input_element.send_keys(text)
input_element.send_keys(Keys.RETURN)
# Close the browser
driver.quit()
This is the error I receive "Traceback (most recent call last):
File "C:\Users\*******\********\*******\untitled\venv\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\*******\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\*******\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\*****\*******\******\untitled\Main.py", line 8, in <module>
text = pytesseract.image_to_string(image)
File "C:\Users\******\********\*******\untitled\venv\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string
return {
File "C:\Users\******\********\*******\untitled\venv\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\*********\******\*******\untitled\venv\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\*******\*******\*********\untitled\venv\lib\site-packages\pytesseract\pytesseract.py", line 260, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information."
I couldn't figure out what the problem was.