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

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

@Volkan_Gumuskay 

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

Screenshot 2023-07-12 at 5.57.18 PM.png

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