Issue
I have a textfile containing the source code for an Ipython Notebook.
How can I convert this file using Ipython / Python to an Ipython Notebook?
e.g. :
source.txt:
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test"
]
},
}
...
The questions on SE deal with converting an actual notebook to a .py or otherwise. I'm looking just to get to the notebook in the first place.
Edit: I'm on Mac
Solution
You need to first install iPython package
pip install ipython
Save your current file as .py file using notepad++ Then try below code
import IPython.nbformat.current as convert
conv = convert.read(open('source.py', 'r'), 'py')
convert.write(conv, open('source.ipynb', 'w'), 'ipynb')
Answered By - DeshDeep Singh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.