Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import json
import sys
if len(sys.argv)!=2:
print "Usage: FILENAME"
with open(sys.argv[1]) as data_file:
ipynb = json.load(data_file)
code = ""
for c in ipynb["cells"]:
if c["cell_type"] == "code":
source = c["source"]
for s in source:
if s[0] != "%":
code += s.rstrip('\n')+"\n"
exec code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment