Created
September 16, 2018 20:41
-
-
Save marknagelberg/cb31ff6c2902e33bea22898c828bab80 to your computer and use it in GitHub Desktop.
Generate HTML reports for PDF in Python Blog Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jinja2 | |
| templateLoader = jinja2.FileSystemLoader(searchpath="./") | |
| templateEnv = jinja2.Environment(loader=templateLoader) | |
| TEMPLATE_FILE = "pdf_interest_report.html" | |
| template = templateEnv.get_template(TEMPLATE_FILE) | |
| for d in data_frames: | |
| outputText = template.render(df=d['df'], | |
| interest_rate=d['interest_rate']) | |
| html_file = open(str(int(d['interest_rate'] * 100)) + '.html', 'w') | |
| html_file.write(outputText) | |
| html_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment