TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Automate PowerPoint Slide Creation with Python

Boost your Productivity with an Automated Tool for the Creation of Supply Chain Operational PowerPoint Reports with Python

Samir Saci
TDS Archive
Published in
8 min readSep 26, 2022

--

A flowchart illustrating the automation of PowerPoint slide creation for supply chain operations using Python. The process starts with 5 weeks of operational activity data from a warehouse database. SQL queries extract prepared order lines, which are processed by Python scripts to calculate KPIs. The output is a PowerPoint report showing warehouse workload and order profiles per week.
(Image by Author)

Do you spend more time creating PowerPoint presentations than analyzing data?

With Python, you can automate the creation of PowerPoint presentations and focus on what matters — bringing insights using data.

In this article, we’ll show you how to use Python to build an automated tool that generates PowerPoint slides with visuals and comments.

This will give you more time to make strategic decisions and boost productivity.

SUMMARY
I. How can you create PowerPoint presentations with Python?

Discover the result using the example of a weekly operational report
1. Use Data to Prepare Monthly Operational Reviews
A manual process to extract and process data to prepare a PowerPoint
2. Streamline the process of PowerPoint decks creation with Python
Fully automated workflow from data extraction to PowerPoint file creation
3. Results
PowerPoint slides generated with visuals, graphs and comments
II. Process Data and Design Slides with Python
Let's explore the Python code to generate the content of the PowerPoint
1. Data Extraction & Processing
Python scripts to query a database and process the data in dataframes
2. Create visuals & add comments
Using matplotlib and comment templates that we fill with results from data
III. Create the PowerPoint Decks with Python-pptx
Include visuals and contents in PowerPoint slides using Python
1. Introduction Slide
Start with the first slide including a title
2. Daily Analysis Slide by WEEK
Generate the slides with the graphs and comments created previously
IV. Conclusion & Next Steps
We have now implemented an automated workflow to generate PowerPoint slides
1. Automate Report Distribution with Python
Complete the workflow with a tool to automatically send your email the report
2. Boost your Solution with Generative AI: The Smart "GPT"
Improve the user experience with a smart agent that can adapt the report

How can you create PowerPoint presentations with Python?

You are a data scientist in the distribution planning team of an international clothing retailer with stores on all continents.

A flowchart illustrating the supply chain process for a clothing retailer. It shows the factory producing goods and sending replenishment orders to the warehouse. The warehouse prepares the goods (pick and pack) and delivers them to stores. Supply planners handle replenishment orders, and distribution planners manage delivery orders to sales channels (retail stores).
Logistics Network — (Image by Author)

Your distribution network includes several local warehouses that replenish the stores.

To perform analysis, you connect to the warehouse management system to extract and process data using an automated tool built with Python.

However, you have to spend time manually putting these visuals in slides for your weekly operational reviews.

What’s your role?

Use Data to Prepare Monthly Operational Reviews

At the end of the month, you organize an operational review with the store managers to assess the performance of the distribution network.

To animate the discussion, you prepare some slides,

  1. Extract data from the Warehouse Management System (WMS)
  2. Process data and built visuals with Python
  3. Prepare a PowerPoint presentation

How can you automate this process?

Streamline the process of PowerPoint deck creation

To be efficient, you would like to automate the creation of a PowerPoint deck.

Your solution will be fully automated.

  • Extract order lines of the last month from the WMS SQL database
  • Process the data and compute KPIs with key insights by week
  • Automatically put the visuals and insights in a PowerPoint presentation
A flowchart illustrating the automated creation of PowerPoint slides for supply chain reports. It starts with 5 weeks of operational data from a warehouse management system database. SQL queries extract prepared order lines, which are processed by Python scripts to calculate KPIs. The output is a PowerPoint report with weekly warehouse workload and order profile visuals.
Process in 4 steps — (Image by Author)

What is the output?

Results

The final deck will have slides like the ones below:

  • Five slides with visuals of the daily workload (left) and one slide for the monthly analysis of the order profile (right)
  • A visual generated with Python
  • A comment area will provide insights based on the visual
A PowerPoint slide titled “Warehouse Workload (WEEK-1)” and “Order Profile” displaying two visuals generated with Python. The left chart shows the warehouse workload per day with a bar chart, and the right chart displays the order profile with the split of orders by the number of lines. Below each chart are insights, such as the number of orders and lines prepared during the week. A highlighted comment area at the top provides updated information and comments.
Final Results — (Image by Author)

Now that you know the final result, let me show you how to build the tool.

Process Data and Design Slides with Python

Let us explore all the steps to generate your final report.

A diagram illustrating the process of automating PowerPoint slide creation for supply chain workload analysis. The left side shows multiple PowerPoint slides with charts depicting warehouse workload analysis over five weeks and an order profile. The right side details the process: extracting records from a database using SQL queries, processing and calculating KPIs, building charts, saving them as .png files, and finally creating PowerPoint slides.
Steps to create your operational report on PowerPoint — (Image by Author)

Where to find the data?

Data Extraction

Connect to your WMS and extract shipment records

  • Create your SQL Query to extract shipment records
  • Use pandas.read_sql_query to do the query
  • The results will be in a pandas data frame

If you don’t have access to a WMS database, you can use the dataset shared on GitHub at the end of the article.

Do we need to process the data? Yes!

Process the data

Add a column that calculates the number of lines per order using pandas.

Now that we have processed data, let’s create charts.

Create the visuals

Create a simple bar plot chart that shows the number of Lines and Orders prepared per day.

Example of bar plot visual designed with python for powerpoint slides
Bar plot— (Image by Author)
A stacked bar chart titled “Split of orders by number of lines/order” showing the distribution of orders with different numbers of lines per week. The chart compares five weeks, with Week 2 having the highest total number of orders (over 6000), and Week 5 the lowest (under 1000). The colors represent the number of lines per order, ranging from 1 line (blue) to 5 or more lines (gray), with most orders containing just 1 line, followed by a smaller proportion with 2 to 5+ lines.
Stacked Bar Plot — (Image by Author)

Save the charts

To be added to the PowerPoint, you need to save it locally.

Charts alone may be challenging to analyze.

We can add observations.

Add comments and insights.

You can add comments based on the chart you share that will summarize each week's performance.

Include these comments under the visuals for more clarity.

Example of comments — (Image by Author)

Which indicators do they monitor to manage the distribution process?

These comments should be based on the needs of the operational teams.

We can start creating our decks now that we have visuals and text.

If you prefer watching, have a look at the YouTube tutorial!

🏫 Discover 70+ case studies using Python to automate boring tasks and support business optimization 🏪 in this Cheat Sheet

Create the PowerPoint Decks with Python-pptx

I am using the open-source library python-pptx to build our PowerPoint decks.

Let’s start with an introduction slide.

Introduction Slide

We will start with a special introduction slide at the beginning of the presentation.

A slide with a dark blue background displaying the title “WAREHOUSE WORKLOAD ANALYSIS” in large white text, followed by the subtitle “Orders/day for the last 5 weeks” in smaller white text. This slide appears to be the title page of a PowerPoint deck summarizing the workload of a warehouse over a 5-week period.
First Slide — (Image by Author)

Code

We can now add analyses using the charts and text generated in the previous section.

Daily Analysis Slide by WEEK

The structure of your slide will always be the same

  • A title on top (e.g: Warehouse Workload (WEEK-5))
  • A picture at the centre of the slide
  • A text box for the comment area
Structure of the slides automatically created with python-pptx
Slide Structure — (Image by Author)

Code

💡 TIPS
You can change the position of the objects by modifying the parameters of Inches() functions.

We move on to another analysis using the second chart that was generated.

Weekly Analysis of Order Profile

In this slide, you will use a stacked bar plot chart, and the comments will be based on the entire month's scope.

Order Profile — (Image by Author)

Code

💡 TIPS
You can change the font size by modifying the parameter of the functions Pt().

Finally, you have a PowerPoint file with seven slides ready for your meetings.

A preview of seven PowerPoint slides titled “Warehouse Workload Analysis” displaying the workload in terms of orders and lines over the past five weeks. The first slide introduces the analysis, followed by individual slides summarizing each week’s workload, labeled “Warehouse Workload (WEEK-1)” through “Warehouse Workload (WEEK-5).” The final slide titled “Order Profile” presents a breakdown of orders by the number of lines per order across the five weeks.
PowerPoint Final — (Image by Author)

You can find the source code with dummy data in this GitHub repo,

Do you need additional clarification? Feel free to comment!

💡 Follow me on Medium for more articles related to 🏭 Supply Chain Analytics, 🌳 Sustainability and 🕜 Productivity.

Conclusion & Next Steps

This simple example gives you a template to build your PowerPoint automation solution.

As a data scientist, I don’t want to spend my time creating powerpoints.

You can now,

  • Add visuals, tables or smart visuals of PowerPoint (check the documentation)
  • Bring more insights or enrich the text with conditions

This Python script can be launched locally on your computer or deployed on a web application.

What if you want to distribute this report? There is a solution for that!

Automate Email Reporting

You can automate the report distribution by email using the Python SMTP library.

In another article, I developed a simple Python script deployed on the cloud that automatically performs these four steps:

  • Extract prepared order lines of last week from the WMS SQL database
  • Process the data and compute KPIs with key insights
  • Automatically send an HTML email with visuals and comments
A flowchart illustrating the process of automating email reporting for warehouse operations. The process begins with “1 week of operational activity” from the “Warehouse Management System,” followed by “SQL queries” to extract prepared order lines. The data is then processed and KPIs are calculated using “Python scripts,” and the final report is “sent by email” with visuals included in an HTML report. Each step is represented by icons, with arrows indicating the flow of data.
Process in 4 steps — (Image by Author)

Instead of having a PowerPoint document, we send an HTML page with the same visuals and comments.

For more information, have a look at this article

Have you heard about Generative AI?

Boost your Solution with Generative AI: The Smart “GPT”

You can find in another article my explorative journey of Large Language Models (LLMs) used to improve the user experience for reporting and advanced analytics products.

A series of icons representing the process of enhancing a solution with Generative AI for reporting and analytics. The icons depict a sequence starting with question marks (indicating a problem or query), followed by machine learning or data processing icons, a database labeled “SQL,” more data processing icons, and finally a person receiving a response (indicating a solution or answer from the AI). The flow illustrates how AI and SQL can be combined to improve user experience for reporting.
Supply Chain Control Tower Agent with LangChain SQL Agent [Article Link] — (Image by Author)

This experiment aims to design an intelligent agent equipped with a GPT model and connected to a database.

  1. Users ask operational questions: “Where is my shipment?”
  2. The agent queries the database and extracts the results.
  3. The agent replies with a proper answer.

Can we use this agent to generate the observations based on user requests? The answer is Yes!

After OpenAI introduced ChatGPT's advanced features, we can deploy solutions like this PowerPoint automation script in a custom GPT.

Users would upload data, and the agent would prepare the Powerpoint.

A flowchart showing how a GPT-based intelligent agent processes user data for analysis. Step 1 involves uploading a CSV dataset or using a sample. Step 2 allows selecting variables like quantity or turnover. The agent generates insights, including sales distribution and demand variability charts (Pareto and ABC), and answers user questions based on the data, automating PowerPoint generation.
“The Supply Chain Analyst” — (Image by Author)

You can get inspiration from the Supply Chain Analyst”, a custom GPT agent I’ve designed to automate supply chain analytics tasks and interact with users using natural language.

Have a look at these case studies if you need inspiration,

About Me

Let’s connect on Linkedin and Twitter. I am a Supply Chain Engineer who uses data analytics to improve logistics operations and reduce costs.

For consulting or advice on analytics and sustainable supply chain transformation, feel free to contact me via Logigreen Consulting.

If you are interested in Data Analytics and Supply Chain, look at my website.

💌 New articles straight in your inbox for free: Newsletter
📘 Boost your Productivity with Data Analytics: Productivity Cheat Sheet

--

--

Samir Saci
Samir Saci

Written by Samir Saci

Top Supply Chain Analytics Writer — Case studies using Data Science for Supply Chain Sustainability 🌳 and Productivity: https://bit.ly/supply-chain-cheat

Responses (1)