Skip to main content

Quickly create HTML reports using a set of JINJA templates

Project description

REPORTS

https://badge.fury.io/py/reports.svg https://travis-ci.org/cokelaer/reports.svg?branch=master https://coveralls.io/repos/github/cokelaer/reports/badge.svg?branch=master Documentation Status
Python version:

Python 3.7, 3.8, 3.9

Online documentation:

On readthedocs

Issues and bug reports:

On github

Reports is a Python package that provides tools to create HTML documents. It is based on a set of JINJA templates and a class called Report. In addition tools such as HTMLTable can help in the creation of HTML table to be included in the report.

The package relies on Pandas for the HTML table creation, as shown in the example below.

We provide a simple JINJA example (stored with the pacakge in ./share/data/templates/generic directory) and we let the users design their own templates.

This is used in GDSCTools.

Warnings

Reports is maintained but no new future will be added. It is maintained for the GDSCTools project but if you find it useful please feel free to use it.

Installation

pip install reports

Usage

Example

Here below, we show the code used to create this example.

# We will create a Report and insert an HTML table in it
from reports import Report, HTMLTable

# Let us create some data. It will be a HTML table built using Pandas
# but you could create the HTML table code yourself.
import pandas as pd

# create a dataframe to play with. Note that there is a numeric column
# In addition, there is a column (Entry name) that will be transformed into URLs
df = pd.DataFrame({
    "Entry name":["ZAP70_HUMAN", "TBK1_HUMAN"],
    "Entry": ["P43403", "Q9UHD2"],
    "Frequency": [0.5,0.9]})

# From reports, we convert the dataframe into a HTMLTable
table = HTMLTable(df)

# a numeric column can be colorized
table.add_bgcolor('Frequency', cmap="copper")

# part of URLs can be added to the content of a column
table.add_href('Entry', url='http://uniprot.org/uniprot/', suffix="")
html = table.to_html()

# Create a generic report. It has a set of tags that can be filled
# using the **jinja** attribute.
r = Report("generic")

# set the **summary** tag with the HTML code of the table
r.jinja['summary'] = html

# Generate and show the report
r.create_report(onweb=True)

See the results in example

Using your own JINJA template

Create a directory called test and add a file called index.html

Add this code:

<h1> {{ title }} </h1>
<p> Number of reads : {{ reads }} </p>

Now, create your HTML files:

from reports import Report
report = Report("test")
report.jinja['title'] = 'Simple Example'
report.jinja['reads'] = "123456"
report.create_report(onweb=True)

Issues

Please fill bug report in https://github.com/cokelaer/reports

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reports-0.4.1.tar.gz (150.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page