-
-
Save izikeros/2259c87ab270f56c83cf79c62db69054 to your computer and use it in GitHub Desktop.
[Databricks notebook to ipynb] Approximately convert DataBricks notebook (unzipped .dbc file) to ipynb using jq #jupyter #databricks #notebook #jq
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
.language as $lang | | |
{ | |
"metadata" : { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"cells": .commands | [ | |
.[] | | |
( | |
.command | | |
(capture("^%(?<cellLang>\\w+)\\s(?<remainder>.*)") // {cellLang: $lang, remainder: .}) | |
as { $cellLang, $remainder } | | |
{ | |
cell_type: (if $cellLang == "md" then "markdown" else "code" end), | |
source: [ | |
if $lang == $cellLang or $cellLang == "md" then "" else "%%" + $cellLang + "\n" end, | |
$remainder | if $cellLang == "md" then gsub("(?<head>(^|\n)#+)"; "\(.head) ") else . end | |
], | |
metadata: {} | |
} | | |
. + if .cell_type == "code" then {outputs: [], execution_count: 0} else {} end | |
) | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment