import json nb = json.load(open('01.train_ODC.ipynb')) for idx, cell in enumerate(nb['cells']): if cell['cell_type'] == 'code': print(f"Cell {idx}:") print("".join(cell['source'][:3])) print("-" * 20)