Skip to content

Instantly share code, notes, and snippets.

@EricSchles
Created September 10, 2020 16:37
Show Gist options
  • Save EricSchles/f86b874c3840a6619aff0c5752c114c0 to your computer and use it in GitHub Desktop.
Save EricSchles/f86b874c3840a6619aff0c5752c114c0 to your computer and use it in GitHub Desktop.
count the number of lines in your jupyter notebooks
from glob import glob
from json import load
def loc(nb):
cells = load(open(nb))["cells"]
return sum(len(c["source"]) for c in cells)
root_folder = "~"
summation = 0
for File in glob(root_folder+"/**/*.ipynb", recursive=True):
summation += loc(File)
print(summation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment