Python 3, openPyXl, os, shutil on Windows 10
As an academic administrator, I have to prepare 70 empty grade report spreadsheets templates at the end of each academic quarter: one for each of my teachers. Each copy of the template sheet needs to be named with the teacher’s name and class number. Then the quarter, title and year is appended to the end. For example:
Stephen Hawking 404-23 Q3 Grades 2017.xlsx
The hard way would be copy and paste a file click the file and rename it, repeating the process 70 error-prone and mind wastingly dull times. I could also get the teachers to rename the file, but…they are teachers, not administrators so…yeah…errors again.
Python 3 to the rescue:
Continue reading “How to make multiple copies of a file with Python 3 and a file name list from an Excel sheet”
Python 3, pytube, os in Windows 10
Some of my friends live in an area that really struggles to get decent internet speeds in the afternoons and evenings. So much so that they can barely watch a YouTube video at 144p some days, and that is not particularly useful if they are trying watch a video with code or some technical specs on the screen.
They really needed to download the videos, but really did not trust the programs available online to download videos for me without spamming them with advertising or adding some malicious malware to their beloved computers.
Fortunately, someone developed a Python 3 library to do just that – pytube. In an earlier post I dive into some of the main aspects pytube:
How do I download YouTube videos with Python 3 using Pytube?
In this post I am going to show you a quick app that can be run in the Python shell to download videos that features a progress indicator (not quite a progress bar).
I’ve intentional kept the program fairly limited so you can focus on the important parts. I’ll show you the code and an example of what it looks like when it is running first and then give you the breakdown where you can focus on what you need to know and ignore the rest.
Continue reading “How to Create a Simple YouTube Download Program with a Progress Indicator in Python 3 with pytube”
Python 3, OS, Example in Windows 10
If you are creating a program for a user where you want to store or use a file in the users home directory, it is not as easy as simply preparing a fixed file location like:
Because if another user on another computer tries to use your program they will start getting errors because their home directory might be something else like:
You can, however, get the users home directory by using Python’s
>>> import os
>>> home = os.path.expanduser('~')
Continue reading “How to Check a Users Home Directory for a Folder – Python 3”