Created
July 29, 2020 01:10
-
-
Save ffreitasalves/a2a3fad1b092432272a9ba921fee9e35 to your computer and use it in GitHub Desktop.
Modifying multiple existent Ipython Notebooks using nbformat API
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 os | |
import nbformat | |
warning_message = '### Developers warning: This notebook was generated using XPTO' | |
nb_warning_cell = nbformat.v4.new_markdown_cell(warning_message) | |
for root, dirs, files in os.walk("."): | |
for file in files: | |
if file[-6:] == '.ipynb': | |
nb_path = os.path.join(root, file) | |
current_nb = nbformat.read(nb_path, as_version=4) | |
current_nb['cells'].insert(0, nb_warning_cell) | |
nbformat.write(current_nb, nb_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment