Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- daily
- Q
- bigquery
- SQL
- tableau
- review
- AZURE
- GPT
- 책리뷰
- AWS
- 빅쿼리
- Python
- 구글애널리틱스
- 데일리
- Adobe
- ChatGPT
- Ga
- 데이터시각화
- diary
- 북리뷰
- 챗GPT
- r
- 태블로
- 파이썬
- 생성AI
- 필사
- 데이터분석
- datastudio
- 서평
- openAI
Archives
- Today
- Total
가볍게 배우고 깊게 즐기고 오래 남기기
[Pyton || Tip] nbformat 라이브러리를 활용한 노트북파일(ipynb) py변환 본문
Programming & Tip/Python
[Pyton || Tip] nbformat 라이브러리를 활용한 노트북파일(ipynb) py변환
Awesomist 2024. 5. 20. 14:03728x90
import nbformat
notebook_path = 'name.ipynb'
with open(notebook_path, 'r', encoding='utf-8') as f:
notebook = nbformat.read(f, as_version=4)
code_cells = [cell for cell in notebook.cells if cell.cell_type == 'code']
script_content = "\n\n".join(cell.source for cell in code_cells)
# Save the script to a .py file
script_path = 'name.py'
with open(script_path, 'w', encoding='utf-8') as f:
f.write(script_content)
script_path
https://github.com/jupyter/nbformat
GitHub - jupyter/nbformat: Reference implementation of the Jupyter Notebook format
Reference implementation of the Jupyter Notebook format - jupyter/nbformat
github.com
반응형
'Programming & Tip > Python' 카테고리의 다른 글
Comments