2025-10-20 20:59:48 -07:00

1.2 KiB

Program Explanation

Overview

This program extracts text from an image containing names and scores, parses the data, and saves it into an Excel sheet. The current date and time in PST are also added to each record.

Steps

  1. Text Extraction:

    • The pytesseract.image_to_string function is used to extract text from the image.
    • The Pillow library is used to open and process the image.
  2. Parsing:

    • The extracted text is split into lines.
    • Each line is further split into words. The last word is assumed to be the score, and the rest are combined to form the name.
    • The program ensures that the score is a valid integer before adding the data.
  3. Date Handling:

    • The datetime and pytz libraries are used to get the current date and time in the PST timezone.
    • The date is formatted as YYYY-MM-DD HH:MM:SS.
  4. Excel Writing:

    • The openpyxl library is used to create and write data into an Excel file.
    • The data is written into three columns: Player Name, Player Score, and Date (PST).

Requirements

Libraries

Install the required libraries using pip:

pip install pytesseract pillow openpyxl pytz