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: 

Is there a way to run a single or selected lines in a notebook?

Volkan_Gumuskay
New Contributor III

Assume we have a given cell

print('A')
print('B')
print('C')

I want to run only the below line.

print('B')

Obviously, I can seperate the cell into three and run the one I want, but this is timely. This is a feature I use so often (e.g. in pycharm) and would like to know if there is any way in Databricks notebook, preferably with a keyboard shortcut.

1 ACCEPTED SOLUTION

Accepted Solutions

Volkan_Gumuskay
New Contributor III

With the new editor it is possible for some time now. Posting here for convenience.

Just select the lines and press ctrl+shift+enter 

View solution in original post

6 REPLIES 6

LearningDatabri
Contributor II

This looks promising. I am not aware of this. Would you mind sharing the snaps from pycharm?

I am guessing you want to know how to do this in PyCharm. In PyCharm Community Edition 2021.2, File>Settings>Keymap> type 'execute' in search bar. I am using Ctlr+Enter.

image.pngimage.png

Vivian_Wilfred
Honored Contributor
Honored Contributor

Hi @Volkan Gumuskaya​ I am afraid we do not have a way to do this on a notebook command.

Vidula
Honored Contributor

Hi @Volkan Gumuskaya​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Volkan_Gumuskay
New Contributor III

With the new editor it is possible for some time now. Posting here for convenience.

Just select the lines and press ctrl+shift+enter 

Tharun-Kumar
Honored Contributor II
Honored Contributor II

@Volkan_Gumuskay 

This is also available as an option in the notebook run options.

Screenshot 2023-07-12 at 5.57.18 PM.png

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!