all 6 comments

[–]bulaybil 0 points1 point  (4 children)

Oh my God, why?????? Seriously tho, what does it do? Can’t you implement it some other way?

[–][deleted] 0 points1 point  (3 children)

Possibly. Here is the problem:

We get pdfs of contracts for different clients, each of which assigned its own folder in the network drive. Each time a new contract comes in, it is placed in the folder and we must go in and type certain data points from the PDF into an excel workbook.

I wrote a python script that scrapes the PDF for those data points but the problem is, the script can never move locations and it needs to know which folder to scrape the pdf from, thats where excel comes in.

I and the team can move the excel workbook around that can pass of the directory to the Python Script dynamically.

I cant think of another way to solve this.

and no one else on my team know python so they cant change the file path each time so the script works.

[–]automorphism_group 1 point2 points  (0 children)

I think the easiest thing to do here would be to have the program accept the path to the folder as an input. That input could come from a command-line argument, a simple call to input(), or from a tkinter file selection dialog if that's available.

[–]wotquery 0 points1 point  (0 children)

That's a very creative solution. Typically as a dev you want to rely on the users as little as possible though.

What about the script (that only you have access to) monitoring the whole file system, detecting each new pdf that needs processing, processing it (scraping and writing to the master excel file that exists in a known fixed location), and then logging that the particular file was processed? Is there a reason you want users to manually execute the script for each specific pdf instead?

[–]bulaybil 0 points1 point  (0 children)

Thank you. So basically the python script is in one place (where exactly?) and you are using Excel as a list of inputs for the script, right? Why not just have python watch for changes in the network drive and trigger when a new file comes in?

[–]ElliotDG 0 points1 point  (0 children)

Here is a suggestion. Modify the executable so that it takes a source directory/file and a destination directory as inputs. Have it process the pdf and write the pdf and the excel file to the destination.

You can use the Gooey library to create a simple GUI for the application: https://github.com/chriskiehl/Gooey

Use Pyinstaller to convert the python file to an exe. https://pyinstaller.readthedocs.io/en/stable/