Skip to content
Advertisement

convert jupyter notebook saved as .HTML file back into .IPYNB

Can I convert a Jupyter Notebook saved as .HTML file back into .IPYNB file? The executable original notebooks were lost. The nbconvert docs don’t have anything useful for this case. Currently I have to copy-paste bunch of cells into a new notebook, but this is very tedious and output cells will be lost this way.


[EDIT]

I found an interactive way to do this using BeautifulSoup:

IPython notebook: Convert an HTML notebook to ipynb

Advertisement

Answer

REMOVED ANSWER ATTEMPT because pandoc only results in a markdown representation of the notebook input and output cells as a single notebook cell.

Best I found so far that gets at the OP’s question is here. I’ve added a notebook demonstrating it. You can work through it in your browser in temporary sessions launched from here and served via the MyBInder service. Go there and click on launch binder to get started. This way everything there is already set to try it all out without needing to touch your own machine or computational environments.
Bear in mind it isn’t perfect as notebook .ipynb to HTML is meant to be one-way. BEST TO ALWAYS KEEP YOUR ORIGINAL .ipynb files; clear out output if absolutely necessary to save space.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement