top of page

Make html tables pretty again with python

During one of our projects, we had to automate the process of sending information by email. This status had to include a table that should summary critical elements. We wanted to propose our client 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 have to build a package ourselves :) 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

31 views0 comments
bottom of page