The Boring Python Office Talk Europython 2018 Edinburgh, Stefan - - PowerPoint PPT Presentation

the boring python office talk
SMART_READER_LITE
LIVE PREVIEW

The Boring Python Office Talk Europython 2018 Edinburgh, Stefan - - PowerPoint PPT Presentation

The Boring Python Office Talk Europython 2018 Edinburgh, Stefan Baerisch 1 Motivation Some things should be boring 2 all images used as part of FreePics subscription The Challenge ! Excel, Powerpoint, Word and PDF are


slide-1
SLIDE 1

The Boring Python Office Talk

Europython 2018 Edinburgh, Stefan Baerisch

  • 1
slide-2
SLIDE 2

Motivation

  • 2

Some things should be boring

all images used as part of FreePics subscription

slide-3
SLIDE 3
  • 3
  • Excel, Powerpoint, Word and PDF are

everywhere

  • They are useful, but can be a lot of effort

to produce by hand

  • Python has modules to automate a lot
  • f document creation

!

The Challenge

slide-4
SLIDE 4

What you should get from this Talk

  • 4

Awareness of great Python Modules Some Pointers Sample Code

This Talk

Great Modules

Your Part

Your Tasks Some Work

https://github.com/stbaercom/europython2018_boring

slide-5
SLIDE 5

What you should get from this Talk

  • 5

I have no time ! We’ll start simple

Perfectionist Pragmatist

slide-6
SLIDE 6

Things we want Python to do.

  • 6

Combine Information from multiple existing Excel Files Add the table and chart from the result file to a Power Point Presentation Create a PDF for Archiving

1 2 3

slide-7
SLIDE 7

Modules Used

  • 7

So many modules… You do not need much from each to begin with

XlsxWriter pandas pdfrw python-pptx reportlab python-docx

  • penpyxl

Used to combine inputs and produce pivot table Can also read / change Excel Files. See Github Used to create the Excel with charts, etc. Used to combine PDF files Can create custom

  • PDFs. Not really

used In headless mode. Can “print” to PDF Used to change and Create PPTX files

PandasToPowerpoint

slide-8
SLIDE 8

Overall Program Flow

  • 8

1 2 3

This is an example. You do not need pandas, you can use just Python. You can create text-heavy PPTXs without tables and charts, but with nice images…

slide-9
SLIDE 9

Excel and Python

  • 9

1. Read 3 Files common table 2. Do some cleanup 3. Build a pivot and a Chart

project_hours.xlsx project_rates.xlsx project_expenses.xlsx

slide-10
SLIDE 10

Loading the Input Files

  • 10

Now, this is rather boring…

slide-11
SLIDE 11

Data Transformation and Pivots

  • 11
slide-12
SLIDE 12

Simple Export to Excel

  • 12
slide-13
SLIDE 13

Adding an Introduction Sheet

  • 13
slide-14
SLIDE 14

Writing Data to the Excel "by Hand"

  • 14
slide-15
SLIDE 15

Custom Formats by Hand (1/2)

  • 15
slide-16
SLIDE 16

Custom Formats by Hand (2/2)

  • 16
slide-17
SLIDE 17

Tables & Conditional Formats (1/2)

  • 17
slide-18
SLIDE 18

Tables & Conditional Formats (2/2)

  • 18

Boring, but colorful

slide-19
SLIDE 19

Creating Charts (1/2)

  • 19
slide-20
SLIDE 20

Creating Charts (2/2)

  • 20
slide-21
SLIDE 21

So much for Excel

  • 21

We do have your Excel Files Almost perfect. Even with the charts and conditional formatting I like And from now

  • n, you can

have many for files…

slide-22
SLIDE 22

Powerpoints with PPTX

  • 22

The slide master is ugly on

  • purpose. Really.
slide-23
SLIDE 23

Adding Text Boxes and Graphics

  • 23
slide-24
SLIDE 24

Adding Table Data to a Slide

  • 24
slide-25
SLIDE 25

Adding Charts to a Slide (1/2)

  • 25
slide-26
SLIDE 26

Adding Charts to a Slide (2/2)

  • 26
slide-27
SLIDE 27

So much for PPTX

  • 27

And now of have some

  • Powerpoints. They

even use the new Company Master Ugly but useful. And for once, even in time. And we did not even get into Shapes… I still need PDFs to send to OtherBoss

slide-28
SLIDE 28

PPTX to PDF with Libreoffice CLI

  • 28
slide-29
SLIDE 29

Combining PDF Files

  • 29
slide-30
SLIDE 30

So, what have we done

  • 30

1 2 3

Build a formated Excel Table with Data from Pandas

Task Things we did

Applied formats, conditional formats, and tables with filters Created charts Created a PPTX based on an existing template Created tables and charts in a PPTX Transformed a PPTX into a PDF via Libreoffice Combined multiple PDFs into a single file

slide-31
SLIDE 31

Where to learn more

  • 31

Books Documentation

https://xlsxwriter.readthedocs.io/ https://python-pptx.readthedocs.io/en/latest/ Automate the Boring Stuff with Python, by Al Sweigart. Free to read under Creative Commons: https://automatetheboringstuff.com/ https://openpyxl.readthedocs.io/en/stable/ ReportLab - PDF Processing with Python, Michael Driscoll, Leanpub https://leanpub.com/reportlab

slide-32
SLIDE 32

The End?

  • 32

Bye!!

https://github.com/stbaercom/europython2018_boring