Spaces:
Sleeping
Sleeping
| import pickle | |
| import nbformat | |
| with open('/code/webpanel_ntbk.ipynb', 'r') as f: | |
| notebook = nbformat.read(f, nbformat.NO_CONVERT); | |
| with open('/code/notebook.pkl', 'wb') as f: | |
| pickle.dump(notebook, f) | |
| with open('/code/notebook.pkl', 'rb') as f: | |
| notebook = pickle.load(f); | |
| code_cells = [cell['source'] for cell in notebook['cells'] if cell['cell_type'] == 'code'] | |
| python_code = '\n'.join(code_cells) | |
| with open('/code/webpanel_ntbk.py', 'w') as fw: | |
| fw.write(python_code) | |
| #with open('/code/webpanel_ntbk.py', 'w') as fw: | |
| # fw.write(repr(app)) | |