0

I have a Python script that loads a CSV file of data and then runs functions on each line using a for loop. It all works great apart from consistently at item number 247 it exits. No error message, I just get returned to a command prompt.

I have tried entering debug statement to narrow down what is happening bu I am still no clearer as there is no error message.

Is there a way to run Windows Python is some sort of verbose mode so I can watch it running and see why my loop is stopping?

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
fightstarr20
  • 11,682
  • 40
  • 154
  • 278

1 Answers1

3

You could use the pdb module, with a selective if condition to invoke it for row containing item 247 only. Something like below, which will enter the interactive debug mode for the case when its not working:

for line in csvfile:
    if row_item == 247:
        import pdb; pdb.set_trace()
    # regular processing here

From there, you can step into the function to understand what is not working.

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186