Creating publication quality tables in python

房东的猫 提交于 2019-12-05 08:02:06
Jules G.M.

Feels like a job for http://matplotlib.org/, as per https://stackoverflow.com/a/8976359/447599.

Could also be a job for ReportLab, as per Python reportlab inserting image into table

The other option would be to output latex source with tabular as per http://en.wikibooks.org/wiki/LaTeX/Tables

If that doesn't suit you, just write .csv files and format the table in excel, and export the image form there, with code like

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

I guess you could also just write an html table file and style it with 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>")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!