cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.