I have an IPython notebook where I\'ve accidentally dumped a huge output (15 MB) that crashed the notebook. Now when I open the notebook and attempt to delete the troubleso
Here is a further modification from @Edward Fung's answer that will output the cleaned notebook to a new file rather than rely on stin
and stout
from nbformat import read, write
def strip_output(nb):
for cell in nb.cells:
if hasattr(cell, "outputs"):
cell.outputs = []
if hasattr(cell, "prompt_number"):
del cell["prompt_number"]
nb = read(open("my_notebook.ipynb"), 4)
strip_output(nb)
write(nb, open("my_notebook_cleaned.ipynb", "w"), 4)