Define a function to load and execute another notebook in this notebook's namespace
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)
Run our example load data notebook
execute_notebook("loaddata.ipynb")
Now do our 'analysis' on that data
%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
plot(x,s,x,c)
[<matplotlib.lines.Line2D at 0x109571150>, <matplotlib.lines.Line2D at 0x1095713d0>]