Skip to content

Instantly share code, notes, and snippets.

@wx13
Created November 14, 2014 22:18
Show Gist options
  • Save wx13/3e4cf47e3572b5e86321 to your computer and use it in GitHub Desktop.
Save wx13/3e4cf47e3572b5e86321 to your computer and use it in GitHub Desktop.
Python script to remove outputs from an ipython notebook (without requiring ipython to be installed)
import json
from sys import argv
def strip_output(nb):
for ws in nb['worksheets']:
for cell in ws['cells']:
if 'outputs' in cell:
cell['outputs'] = []
if __name__ == '__main__':
with open(argv[1],'r') as f:
nb = json.load(f)
strip_output(nb)
print json.dumps(nb,sort_keys=True,indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment