Skip to content

Instantly share code, notes, and snippets.

@natl
Created August 5, 2020 01:54
Show Gist options
  • Select an option

  • Save natl/261b5893e40dde1cfd3ef59a0c9e86df to your computer and use it in GitHub Desktop.

Select an option

Save natl/261b5893e40dde1cfd3ef59a0c9e86df to your computer and use it in GitHub Desktop.
Python Notebook Executor
import os
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
if os.path.exists('./foo.csv'):
os.remove('./foo.csv')
with open('test-notebook.ipynb') as ff:
# This notebook creates foo.csv
nb = nbformat.read(ff, as_version=4)
executor = ExecutePreprocessor(timeout=600, kernel_name='python3')
# This will make foo.csv
out_nb = executor.preprocess(nb)
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment