Creating publication quality tables in python

I would like to create publication quality tables for output as svg or jpg or png images using python.

I am familiar with a text module that creates nice text tables, but if I have, for example,

data = [['Head 1','Head 2','Head 3'],['Sample Set Type 1',12.8,True],['Sample Set Type 2',15.7,False]]

and I wanted to create something similar to

table image

Is there a module that I can access, or can you tell me the process for this?

+6
source share
1 answer

It seems to work like http://matplotlib.org/ , according to fooobar.com/questions/953533 / ....

There might also be a task for ReportLab on Python reportlab that inserts an image into a table

Another option is to output the latex source with the table one in accordance with http://en.wikibooks.org/wiki/LaTeX/Tables

If this does not suit you, just write the CSV files and format the table in excel and export the image form here with a code like

 with open("example.csv") as of: for row in data: for cell in row: of.write(cell + ";") of.write("\n") 

I think you could just write an html table file and create it using css.

 with open("example.html") as of: of.write("<html><table>") for index, row in enumerate(data): if index == 0: of.write("<th>") else: of.write("<tr>") for cell in row: of.write("<td>" + cell + "</td>") if index == 0: of.write("</th>") else: of.write("</tr>") of.write("</table></html>") 
+4
source

Source: https://habr.com/ru/post/953531/


All Articles