Created
April 28, 2017 23:21
-
-
Save agounaris/5da16c233ce480e75ab95980831f459e to your computer and use it in GitHub Desktop.
Word count of markdown jupyter notebook cells
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 io | |
from IPython.nbformat import current | |
with io.open(filepath, 'r', encoding='utf-8') as f: | |
nb = current.read(f, 'json') | |
word_count = 0 | |
for cell in nb.worksheets[0].cells: | |
if cell.cell_type == "markdown": | |
word_count += len(cell['source'].replace('#', '').lstrip().split(' ')) | |
print(word_count) |
Abhyuday10-beep
commented
Dec 16, 2021
It really works after replacing the path with the filename. Thankyou so much.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment