0

For whatever reason, my code is not entering the 'for' loop below in line 85.

The file input_fileA is open. Does anyone have a clue why? This is python 2.7.

 84 if (counter_shiftA == counter_shiftB):
 85     for line in input_fileA:
 86         print line
 87         if shiftBEntryA.strip() in line:
 88             print "Hit a matched line"
 89             counter1 += 1
 90             flag = True
 91             output_file.write(line)
 92         elif shiftEEntryA.strip() in line:
 93             output_file.write(line)
 94             break
 95         elif flag:
 96             output_file.write(line)
12
  • what is the declaration of input_fileA? Commented Jul 24, 2017 at 23:06
  • Does counter_shiftA == counter_shiftB evaluate to True? Commented Jul 24, 2017 at 23:06
  • Is input_fileA already exhausted? Or empty? Commented Jul 24, 2017 at 23:06
  • 1
    Is it going in to your condition? What does input_fileA look like? Commented Jul 24, 2017 at 23:08
  • Yes, the counter_shiftA == counter_shiftB statement is true and works. Commented Jul 24, 2017 at 23:10

1 Answer 1

1

You can try adding input_file1.seek(0) before for line in input_file1.readlines(): of line 87. Since, you mentioned you have called the line before. For more details, you can check discussion here

Sign up to request clarification or add additional context in comments.

1 Comment

Great! Happy Coding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.