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

Tic-Tac-Toe in JavaScript

Tic-Tac-Toe in JavaScript

To take a break from the other projects this weekend I worked on a Tic-Tac-Toe game in JavaScript. The basic instructions I had for myself was it needed to be able to be played by 1 or 2 people. I started with creating the game for 2 players. Thinking that if I can...

read more
Save posts to a WordPress Database – Working Notes

Save posts to a WordPress Database – Working Notes

This is notes/overview of a project I started on to add several posts to WordPress (WP) from HTML files without having to copy and paste each file. These are just notes from that dropped project and the basic Python script to do this (github). Make sure you fully test...

read more
CMYK converter added

CMYK converter added

CMYK is a tricky one, since each device would interpret the colors differently. Had almost decided not to even include it but thought it could be useful at times. Looking around I found a basic formula that most people were using to give a rough idea for the color. I...

read more

Pin It on Pinterest

Share This