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

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!