Skip to content

Misc

notebook_utils

find_notebooks(path, string, cell_type)

If you have a directory containing a whole lot of jupyter notebooks and you need to find the notebook containing a specific string/code, this function is for you.

Usage:

from random_functions.misc.notebook_utils import find_notebooks

string_to_search = "import numpy as np"
dir_to_search = "/home/myuser/notebooks"

find_notebooks(
    path=directory_to_search,
    string=string_to_search,
    cell_type="code,
)

Parameters:

Name Type Description Default
path str

The path where the notebooks(ipynb) are present

required
string str

The word to search for in the notebooks

required
cell_type str

Can be either markdown or code. If the word you wish to search for is in the markdown cell, use "markdown" else use "code".

required