Programmatically edit notebook

lauraxyz
Contributor

I have a job to move notebook from Volume to workspace, then execute it with dbutils.notebook.run(). Instead of directly running the notebook, i want to append some logic (i.e. Save results to a certain able) at the end of the notebook, is there a suggested way for that?

I think we can treat the notebook as a regular file and just append our code into it.  But wondering if there's any built-in feature from Databricks that can handle this gracefully.

Alberto_Umana
Databricks Employee
Databricks Employee

Hi @lauraxyz,

Currently, there is no built-in feature in Databricks that directly supports appending logic to a notebook before execution, so treating the notebook as a regular file and modifying its content is a practical solution.

View solution in original post