I need Python 3 because I'm using a PDF extraction package (PyMuPDF) that won't run in Python 2. This script runs on a standalone basis in PyCharm and retrieves an account number from a PDF document. The script and my flow are shown below.. I am not sure I am passing the variables correctly. I have never done this before. When I execute the script when I get to the display Message action I get a popup asking me to select an application to open a file called Steven (That's my first name) After I select Notepad a document with a lot of log info opens which I am not interested in. A dialog box does open that was supposed to display the result (account number) but it is empty. I made a short (2-minute) screen capture video to demo what's happening. There was no script error. Not sure how to proceed. TIA
https://youtu.be/lu-_xeXigaA
import fitz
import re
import sys
doc = sys.argv[3]
print(doc)
with fitz.open(doc) as pdf:
text = ""
for page in pdf:
text += page.get_text()
pattern = r'(\d{3}[-]?\d{3}[-]?\d{3}[-]?\d{4}|NO\.\d{13};)'
matches = re.findall(pattern, text)
if matches:
result = matches[0].replace("-", "").replace("NO.", "").replace(";", "")
print(result)
else:
print("No match found")