joki
joki

Reputation: 1

setting a "checkpoint" in Pycharm

I am using Python 2.7 with Pycharm and I am working on a quite large text files; they are about 3gb in total.

I need to run LDA, PoS tagging, and other feature extraction methods on the data from the file but everytime I test my code, it has to read the file and go through the same process all over again from the beginning.

This is why I often use Jupyter because all the data / variables in previous cells are kept in memory.

Is there any way to do something similar with Pycharm? For instance, let's say I am adding features to do_some_feature_extraction()

def do_some_feature_extraction(str_list):    
    # feature extraction 1   
    # feature extraction 2

str_list = []
with open("some_file.txt", "rb") as f_in:
     for line in f_in:
          str_list.append(line)

do_some_feature_extraction(str_list)

Let's say, there was an error on "feature extraction 1" and then I fixed it. Then I will run the code again, then there will be another error on "feature extraction 2". Then I will fix it and run the code again from the beginning.

Instead of doing this, can I just set some sort of checkpoint before executing do_some_feature_extraction(str_list) ?

Upvotes: 0

Views: 2267

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 114038

click the left side of your code ... next to the line number(or where the line number would be if you have them turned off)

enter image description here

a red dot should appear (this is called a breakpoint)...

enter image description here

now run it in debug mode

enter image description here

when you reach your breakpoint you can click the console tab

enter image description here

and then click the interactive terminal button(>_) to work directly with the context of the program

enter image description here

Upvotes: 1

Related Questions