cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can I run one notebook from another notebook?

__Databricks_Su
Contributor
 
21 REPLIES 21

@Prabhu4284 When I run Notebook B (which defines a function) it is still not defined in Notebook A. Are you sure we can import all things (functions, variables, etc.)? It appears from the Databricks documentation that only strings can be shared between Notebooks and pointers to data.

ashok_k_gupta12
New Contributor III

I declared a function in notebook commonFunction and called it from other function just by giving this command:

%run ./CommonFunction

I went ahead and used the function defiend in other notebook

infact o could access the variable defined in other notebook and vise versa too.

Makeetelich92
New Contributor II

I have a programming background so restarting my kernel every and running things top to bottom was always common sense to me. I do agree though that it can be misleading and people may not make that assumption. I think one flaw with his programming style at the end that notebooks solve is having the history of how you checked your data throughout the process.

carlitoscanas
New Contributor II

Of course you can, in your primary notebook, use the %run magic command followed by the path or name of the notebook file you want to run, like this:

%run /path/to/other_notebook.ipynb

Gooeylewie
New Contributor II

absolutely you can.
there is databricks documentation explaining everything you need to know here: https://docs.databricks.com/notebooks/notebook-workflows.html

Nam
New Contributor II

YES. You can use this script to do it

%run ./path_to_other_notebook

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