Create an html formatted report

VacuumTube picture VacuumTube · Jan 26, 2011 · Viewed 23.5k times · Source

I have a Python 2.6 app running on Linux that creates a CSV file. From the app, I need to create an HTML report, as a single HTML file, that presents the data from the CSV (probably as a table) and also highlights fields where the values meet certain criteria. Charting type functionality would be a nice to have.

What's the best way to do this?

No GPL stuff please.

Answer

chris picture chris · Jan 26, 2011

Choose a Python csv library from here. Now that you have the data mapped to Python data structures you can iterate on it and create the html. I would use the Jinja2 templating engine which is nicely documented. Highlighting rows/cells would work by setting certain css classes on the respective tr/td elements in the table.