How to Use Open-source Scripts to Automate the Boring Stuff with Python


Python. No, it’s not the animal that slithers through the jungles. Well, it is… But that’s not the Python (capital P) that we’re talking about. Python is a programming language that was designed to be easy to learn, powerful, and fast. In this article, we’re going to do a tutorial of how to set everything up to start automating the boring stuff with Python.

Using Python, you can design and script anything you can imagine. Literally. Any process that requires an action that needs to be repeated can probably be done with Python.

Let’s run through an example shall we?

Let’s say we have a company that likes to save their emails from Outlook to Excel so that they have a backup file for auditing purposes. The company could not find an easy tool, because there really isn’t one, so once a month an employee spends 4 hours cranking out the following process for about 300 emails:

  1. Copy each email’s body text, sender email, and date received data.
  2. Paste the data into columns into a new Excel file.
  3. Save the Excel file by the date period.
  4. Place the Excel file into a folder with all of the emails saved up.
Oof. Just reading this process just gets our brains rolling here at Process Zip! It just so happens that we have just the tool to accomplish such a task, automatically, saving the company those 4 hours each week AND a bunch of errors and headaches.
So let’s get to automating the boring stuff with Python!

Step 1: Get Python 3.8 & PyCharm

Python 3.8 (the latest version) and PyCharm (the place where you build and run Python code) are what we recommend to get started.

To get set up with both, follow the tutorial video below. Why write it when someone else has done a great job explaining it?!


Step 2: Find The Right Pre-built Code

This is where you might get a little tripped up, but that’s okay! A ton of other people have written Python code to automate things, so you just have to fine the right code that fits what you need. Sites like GitHub and Stack Overflow have a lot of code that you can use for free. It just takes the right Googling!

In this case, let’s just say that you’ve already found your code on Stack Overflow, and it says it will do just what you need it to do. Great!

In a new .py script in PyCharm just like how you created the “Hello World” .py file in the tutorial above, name your new .py script “Download Outlook Emails”.

Then, copy the code below and paste it into your .py file.

Step 3: Download & Install Necessary Packages

Packages?! This isn’t Amazon!

Okay okay. Enough dad jokes. Packages are essentially pre-built code that others have created so you don’t have to recreate it, saving you unbelievable amounts of time. It’s one of the reasons why we highly recommend using Python for automating the boring stuff. Programs are already built for you!

To use a package, you need to do 2 things.

  1. You need to download/install it.
  2. You need to import it.

To download and install a package, you need to open your terminal in PyCharm and use the following code:

pip install package-name-that-you-want

Let’s install one required package for our script. It’s psutil.


The packages your program will need will always have the text “Import” in front of each package name in your code, and they’re most likely at the top of your file.

For this program, we have the following packages:

import win32com.client
from datetime import datetime
import os
import xlsxwriter
import psutil

Make sure you install all of the packages. If you don’t, the program will not run!

Step 4: Run & Debug the Program


Time to run the program and download them emails instead of copy/pasting them! Click the green “Run” arrow in the top right hand corner of PyCharm, then follow the prompts in the terminal at the bottom of the screen.

If it doesn’t work, then you need to debug. That’s a WHOLE other monster. If you do see an error happen, just copy the error and Google it. Most likely someone else has faced it, and you can solve it quickly.


If it doesn’t work, then you need to debug. That’s a WHOLE other monster. If you do see an error happen, just copy the error’s text from the terminal and Google it. Most likely someone else has faced it, and you can solve it quickly.


Step 5: Keep Automating the Boring Stuff with Python!

Cool, right? You just automated an entire process using Python, and you really didn’t need to write any code!

This is what’s great about the coding community; they’re very share-happy. Take advantage of all the great codes already created, and automate your processes!

How Process Zip Can Help

No matter what you do, always keep the mindset that your processes can be more efficient and cleaner. It’s a core value here at Process Zip: we find ways to do it better! We’d love to help your business realize the power of open-source scripts to start automating the boring stuff with Python. Check out our automation services, or schedule a free 30-minute consultation. Let’s work together to see how we can zip your business.

Leave a Comment

Your email address will not be published. Required fields are marked *