jupyter-notebook-parser
A Python library to parse cell contents from Jupyter notebooks
Installation
pip install jupyter-notebook-parser
Usage
Parser
from jupyter_notebook_parser import JupyterNotebookParser
parsed = JupyterNotebookParser('my_notebook.ipynb')
parsed.get_all_cells() # returns List[Dict], each Dict is a notebook cell
parsed.get_markdown_cells() # returns List[Dict], each Dict is a markdown cel
parsed.get_markdown_cell_indices() # returns List[int], each is a markdown cell's index
parsed.get_markdown_cell_sources() # returns List[str], each is a markdown cell's text
parsed.get_code_cells() # returns List[Dict], each Dict is a code cell
parsed.get_code_cell_indices() # returns List[int], each int is a code cell's index
parsed.get_code_cell_sources() # returns List[SourceCodeContainer]
source = parsed.get_code_cell_sources()[0]
source.raw_source # str
source.source_without_magic # str (all ipython magics excluded)
source.magics # Dict[int, str] (all magics, from line number to magic text)
Rewriter
from jupyter_notebook_parser import JupyterNotebookParser
from jupyter_notebook_parser import JupyterNotebookRewriter
parsed = JupyterNotebookParser('my_notebook.ipynb')
rewriter = JupyterNotebookRewriter(parsed_notebook=parsed)
rewriter.replace_source_in_code_cell(index=5, new_source='print(2)')
Source code container
from jupyter_notebook_parser import SourceCodeContainer
container = SourceCodeContainer('a = 2\n%timeit b = 2 ** 10\nprint(b)')
container.raw_source # same as the input
container.source_without_magic # 'a = 2\n b = 2 ** 10\nprint(b)'
container.magics # {1: '%timeit'}
Metadata
Release files for jupyter-notebook-parser 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupyter_notebook_parser-0.1.4.tar.gz | 3.9 kB | Without provenance | Details for jupyter_notebook_parser-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter_notebook_parser-0.1.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for jupyter_notebook_parser-0.1.4-py2.py3-none-any.whl |
Total release size: 9.2 kB
Release files / jupyter_notebook_parser-0.1.4.tar.gz
| Download URL | jupyter_notebook_parser-0.1.4.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cc12f6aa54ff73ad28dd29b5e537c8eb943dde4651417fc3697067eeb58faaa
|
|
BLAKE2b-256 checksum How to use checksums |
f0cbe30e3691a8640acc7d22fba70423d8f4b9e726616f9fbc3c4c09ddc98cd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / jupyter_notebook_parser-0.1.4-py2.py3-none-any.whl
| Download URL | jupyter_notebook_parser-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
27b3b67cf898684e646d569f017cb27046774ad23866cb0bdf51d5f76a46476b
|
|
BLAKE2b-256 checksum How to use checksums |
f4a461adb19f3c74b0dc0e411de4f06ebef564b1f179928f9dffcbd4b378f2ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for jupyter-notebook-parser 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.