-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate_notebook_report.py
60 lines (51 loc) · 1.55 KB
/
generate_notebook_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
from nbformat import current as nbf
nb = nbf.new_notebook()
cells = []
cell = nbf.new_code_cell(input="""
import type_curve_monthly
from pptx import Presentation
from pptx.util import Inches
from datetime import date
from pd2ppt import df_to_table
import matplotlib.pyplot as plt
from IPython.display import Markdown
""", metadata={
"slideshow": {
"slide_type": "skip"
}
})
cells.append(cell)
cells.append(nbf.new_text_cell('markdown', "# Daily Report", metadata={
"slideshow": {
"slide_type": "slide"
}
}))
cells.append(nbf.new_code_cell('Markdown("## Generated on {:%m-%d-%Y}".format(date.today()))', metadata={
"tags": [
"hide"
]
}))
apis = ['33025033410000', '33025021910000', '33025032430000', '33025031400000',
'33025024720000', '33025014750000', '33025027960000', '33025021060000',
'33025021030000', '33025014120000', '33025017320000']
for api in apis:
cells.append(nbf.new_text_cell('markdown', "# API = {}".format(api), metadata={
"slideshow": {
"slide_type": "slide"
}
}))
cells.append(nbf.new_code_cell('p = type_curve_monthly.type_curve_plot(api="{}")'.format(api), metadata={
"tags": [
"hide"
]
}))
cells.append(nbf.new_code_cell('type_curve_monthly.type_curve_summary_from_db(api="{}")'.format(api), metadata={
"tags": [
"hide"
]
}))
nb['worksheets'].append(nbf.new_worksheet(cells=cells))
nbf.convert(nb, to_version=4)
with open('report.ipynb', 'w') as f:
nbf.write(nb, f, 'ipynb')