Update to Excel file in Python

December 30, 2021

I went back to create a way to make the script into a stand-alone app that the client can use on their own using PyInstaller. I’ve used PyInstaller before for the calculator program:

https://www.lynnamacher.com/gui-python-calculator-stand-alone-app-with-pyinstaller/

To make this more usable for the client I used Tkinter. When the app opens it will ask for the file to process, I went a little further with this of select the file in a folder. When it gets the file, it also gets the path to that folder. This was done by separating out the path from the file path. From there it would go into a for loop it processes all the .xslx (Excel) files in that folder. Other file extensions can be added to the ‘ext’ variable. In the loop the file name coming in is updated with a ‘_update’ before the extension when it saves a copy, example:

Before: subscriberList-Chicago.xslx
After: subscriberList-Chicago_update.xslx

This way they would have the original, if they needed to look back at it and also have the updated one marked and can better manage their files.

With the Tkinker part of the stand-alone app there’s a window that displays when the file loads and while the application that is open that says:

“Select file in folder…
This window will close when done.”

The program will self-close after the last file is processed:

By not including the ‘root.mainloop()’ element, this is used to keep Tkinker file open till it’s closed out by quitting the app, it will close itself when the last process has finished.

When creating the stand-alone app with PyInstaller I was receiving several errors with:

“<frozen importlib._bootstrap_external>”

A quick update of PyInstaller and creating a basic ‘__init__.py’ file in that folder fixed that problem. The next issue is the final app came out to be over 300MB in size. Thinking this is due to how many libraries that were needed to run this app. I did try again by just importing certain elements and the size stayed the same. Maybe PyInstaller installs the full library or some of these are so huge that even calling out a sub-directory just didn’t save enough to alter the size.

The updated file is in Github:

https://github.com/amacher/excelPullLastNameStandAlone/blob/main/PullLastName_allDir.py

Related Articles

AI as your assistant

AI as your assistant

With all the talk of AI will be taking your job and articles like you don’t need to learn coding AI will do it all for you. I’ve been playing around with AI, decided to try to see how much of what AI can be done for me. I use AI generical throughout the post and not...

read more
Website Contact form using AWS

Website Contact form using AWS

For the next iteration of the HTML form was to set it up to send an email to the web owner using AWS. The purpose behind this is, if you have a HTML site and don’t want to purchase a monthly plan or build and maintain server software. Using AWS for this functionality...

read more
HTML with JavaScript contact form

HTML with JavaScript contact form

Link to the form: https://www.lynnamacher.com/pdf/contactForm_V1.html This is created to be basic test for an AWS contact form test. The full form when filled out will send an email through AWS to the site owner. Instead of creating the normal test form I try to...

read more

Pin It on Pinterest

Share This