-
-
Save maximlt/a9fa4d19ae5bff83422194ca99533faa to your computer and use it in GitHub Desktop.
Clean up the output and metadata of a notebook
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
#!/bin/bash | |
jq --sort-keys --indent 1 \ | |
' | |
(.cells[] | select(has("outputs")) | .outputs) = [] | |
| (.cells[] | select(has("execution_count")) | .execution_count) = null | |
| .metadata = {"language_info": {"name":"python", "pygments_lexer": "ipython3"}} | |
| .cells[].metadata = {} | |
| del(.cells[].id) | |
' "$1" > /tmp/$(basename $1) && cat /tmp/$(basename $1) > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment