i am trying to change my notebook.ipynb with code. For this i want to replace certain strings in the notebook by other strings. how do i go about this?
i used the nbformat library to read and write, and inbetween i want to change/overwrite the code. below code generates a copy of a jupyter notebook
import nbformat as nbf
with open('generictemplate.ipynb', 'r', encoding="utf-8-sig") as g:
nb=nbf.read(g, as_version=4)
##i want to replace a string from the NB here- i need your help here
with open('generictemplate_test.ipynb', 'w') as f:
nbf.write(nb,f)
pass