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

Received AWS Certified Cloud Practitioner Certificate

Received AWS Certified Cloud Practitioner Certificate

This past weekend I tested and received my AWS Certified Cloud Practitioner certification. When I started training for the test I had very little exposure to AWS. I studied for a little over a month, around 60 hours, before taking the test; which luckily I passed on...

read more
Inventory HTML page to a CSV file

Inventory HTML page to a CSV file

As a New Year’s resolution, not mine, they wanted to make sure their online store, reseller site, inventory was up to date. They wanted to make sure their inventory was cleaned up and make sure that what’s listed on the site matches their own inventory. They had been...

read more
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

Pin It on Pinterest

Share This