A Sweet Hack to Cut Your Work in Half: Automatic Python Execution

A Sweet Hack to Cut Your Work in Half: Automatic Python Execution

Automate your Python execution and email the results with VBA, Powershell, and Task scheduler. Abstract: This article covers how to schedule your regular python scripts. Assuming that you

Abstract:_ This article covers how to schedule your regular python scripts. Assuming that you_

  1. Get updated excel reports every day/week/month into a shared Network or email
  2. Have a python script that is up and running to processes your reports and deliver insights in the form of images, worksheets, or other forms of data.
  3. Want to run the process over an extended period at regular intervals of time but heavily dread having to run it manually.

There are fun parts of Data Engineering — like programming and analyzing data. Then there are boring parts, like using the already written programs on a regular basis to get the most recent results. Clearly, nobody wants to do the latter. Here is a quick fix I use to avoid running those scripts which need to be executed daily/weekly/monthly so that this time can be put to use better.

Three words — Macro, Batch, and schedule.

  1. I use a macro to save my incoming excel reports to a location as and when they come. (I get it from a place which performs the analysis and sends a report to me manually. No, there is no way around this).
  2. I set up an outlook rule to run the macro only on desired folders along with few other conditions (sender, subject etc).
  3. write a batch file (.bat), which on clicking executes the script on command prompt.
  4. I schedule the bat file using the Windows Task scheduler to execute the script with the same frequency as the arrival of new excel reports
  5. I write a PowerShell script to email the newest results to all the necessary recipients and then I schedule it to run soon after the bat file executes.

Step 1: Outlook Macros

  1. You can activate VBA scripting in Outlook by activating it in the options pane of outlook.
  2. You will then see that a button for developer tools appears at the top of the window in your outlook homepage.

3. Go to the Developer Tools tab and start-up Visual Basic scripting.

4. Here create a new module and script your code to save incoming attachments.

Easy Peasy.

In the example below, the report name is always the subject of the automated email I get. So I used this criterion to decide the save name of my file and save it to a folder.

(I also make sure to save it with the date so that I know that the destination folder always has the most recent file before executing my script.)

productivity data-science towards-data-science python automation

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Data Science With Python Training | Python Data Science Course | Intellipaat

🔵 Intellipaat Data Science with Python course: https://intellipaat.com/python-for-data-science-training/In this Data Science With Python Training video, you...

Python for Data Science | Data Science With Python | Python Data Science Tutorial

🔥Intellipaat Python for Data Science Course: https://intellipaat.com/python-for-data-science-training/In this python for data science video you will learn e...

Applied Data Science with Python Certification Training Course -IgmGuru

Master Applied Data Science with Python and get noticed by the top Hiring Companies with IgmGuru's Data Science with Python Certification Program. Enroll Now

What Are The Advantages and Disadvantages of Data Science?

Online Data Science Training in Noida at CETPA, best institute in India for Data Science Online Course and Certification. Call now at 9911417779 to avail 50% discount.

50 Data Science Jobs That Opened Just Last Week

Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.