Skip to content

Instantly share code, notes, and snippets.

@inducer
Created February 27, 2014 14:53
Show Gist options
  • Save inducer/9251587 to your computer and use it in GitHub Desktop.
Save inducer/9251587 to your computer and use it in GitHub Desktop.
Script to remove output in IPython notebook
#! /usr/bin/env python3
from json import load, dump
import sys
if len(sys.argv) != 3:
print("usage: %s INFILE OUTFILE", file=sys.stderr)
with open(sys.argv[1], "rt") as inf:
ipynb = load(inf)
for ws in ipynb["worksheets"]:
for cell in ws["cells"]:
cell["outputs"] = []
with open(sys.argv[2], "wt") as outf:
dump(ipynb, outf)
@srhopkins
Copy link

Perfect, Thank you!

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