Created
May 4, 2021 19:46
-
-
Save pagpeter/43561df4cbe08697712d2232037d5b02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
file = "file.ipynb" | |
with open(file, "r") as f: | |
raw = f.read() | |
lines = [] | |
try: | |
for cell in json.loads(raw)["cells"]: | |
if cell["cell_type"] == "code": | |
lines += cell["source"] | |
except: | |
print("Couldnt find code in file") | |
quit() | |
for line in lines: | |
if line.startswith("#@markdown"): | |
print("## " + line) | |
continue | |
print(line, end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A small script to convert iPython files to normal python sourcecode. Warning: iPython functions have to be removed manually