top of page
Writer's pictureRenaud Viot

Make html tables pretty again with python

Updated: Jan 10, 2020

During one of our projects, we had to automate the sending of status by email. This status had to include, in the body of the email, text dynamically updated based on inputs and a table that should summary critical elements. We wanted to propose our client with a choice of table style in order to them to be able to have this status matching its idea.

The backend programming language used is Python and after analyzing the available packages, we realized that we would not find what we were searching for. We created a library that by pass the inherent issues of having a table in the body of the email (CSS limitations due to the email providers for instance).


In this post, we will show you how to send any data frame with a very nicely designed table style in a few lines of code. For this example, we will use the outlook API (please refer to O365 library).


Create a sending email function

In order to make the scripts easy to maintain, we have build a function using the library referenced above:

Install Library

We have published our library in the Pypi environment for everyone to enjoy it. In order to install it, just write the following on the terminal or command line:

Example

Now we just need to import our library and execute the function we built above:

Possible outputs

You can check the full list of colors available in the following pages:

https://pypi.org/project/pretty-html-table/

https://github.com/sbi-rviot/ph_table







Want more information?

Please contact us at ask@simply-bi.com

7,165 views0 comments

Recent Posts

See All

Comments


bottom of page