cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Create new workbooks with code

invalidargument
New Contributor III

Is is possible to create new notebooks from a notevbook in databricks?

 

I have tried this code. But all of them are generic files, not notebooks.

notebook_str = """# Databricks notebook source

import pyspark.sql.functions as F
import numpy as np

# COMMAND ----------

# A test notebook
np.__version__
"""
with open("./notebook.ipynb","w") as f:
    f.write(notebook_str)

with open("./notebook.py","w") as f:
    f.write(notebook_str)

with open("./notebook","w") as f:
    f.write(notebook_str)
1 REPLY 1

invalidargument
New Contributor III

Unfortunaly %run does not help me since I can't %run a .py file. I still need my code in notebooks.

I am transpiling propriatary code to python using jinja templates. I would like to have the output as notebooks since those are most convenient to edit in databricks.

Perhaps calling the workspace API is a possible way forward then? Can i call this from a databrick notebook?
Import a workspace object | Workspace API | REST API reference | Databricks on AWS

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group