From 4b627f055b007d6b943338644544726c1e3af076 Mon Sep 17 00:00:00 2001 From: Ondrej Martinsky Date: Sun, 30 Apr 2017 12:29:41 +0100 Subject: [PATCH] __run_all_jupyter_notebooks.py --- __run_all_jupyter_notebooks.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 __run_all_jupyter_notebooks.py diff --git a/__run_all_jupyter_notebooks.py b/__run_all_jupyter_notebooks.py new file mode 100644 index 0000000..649ba32 --- /dev/null +++ b/__run_all_jupyter_notebooks.py @@ -0,0 +1,32 @@ +import sys +import nbformat +from nbconvert.preprocessors import ExecutePreprocessor +from nbconvert import HTMLExporter + +def tohtml(input, output=None): + if output is None: + output = input + ".html" + + print("Converting %s --> %s" % (input, output)) + ep = ExecutePreprocessor(timeout=300, kernel_name='python3') + + with open(input) as f: + nb = nbformat.read(f, as_version=4) + + ep.preprocess(nb, {'metadata': {'path': './'}}) + + #filename_output = input + ".executed.ipynb" + #with open(filename_output, 'wt') as f: + # nbformat.write(nb, f) + + exportHTML = HTMLExporter() + (body, resources) = exportHTML.from_notebook_node(nb) + + with open(output, 'wt') as f: + f.write(body) + + print("Done") + + +tohtml("binomial_option_pricing/binomial_option_pricing.ipynb") +tohtml("black_litterman/black_litterman.ipynb") \ No newline at end of file