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

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.