Skip to content

Instantly share code, notes, and snippets.

@metafeather
Last active August 29, 2015 14:03
Show Gist options
  • Save metafeather/99f45412554b672ceab6 to your computer and use it in GitHub Desktop.
Save metafeather/99f45412554b672ceab6 to your computer and use it in GitHub Desktop.
IPython - executing other notebooks
import io
from IPython.nbformat import current
def execute_notebook(nbfile):
with io.open(nbfile) as f:
nb = current.read(f, 'json')
ip = get_ipython()
for cell in nb.worksheets[0].cells:
if cell.cell_type != 'code':
continue
ip.run_cell(cell.input)
# Then in another notebook:
execute_notebook("loaddata.ipynb")
@metafeather
Copy link
Author

Originally by ncasagrande

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment