Created
May 29, 2021 19:37
-
-
Save alexeygrigorev/8ac29445e23ecb754960c5cb971cdd58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
NOTEBOOK_FILE = sys.argv[1] | |
print(f'messing up with {NOTEBOOK_FILE}') | |
with open(NOTEBOOK_FILE, 'rt') as f_in: | |
doc = json.load(f_in) | |
cnt = 1 | |
for cell in doc['cells']: | |
if 'execution_count' not in cell: | |
continue | |
cell['execution_count'] = cnt | |
for o in cell.get('outputs', []): | |
if 'execution_count' in o: | |
o['execution_count'] = cnt | |
cnt = cnt + 1 | |
with open(NOTEBOOK_FILE, 'wt') as f_out: | |
json.dump(doc, f_out, indent=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment