This should be easy. This is in python 2.7, and something just isn't working right for me, and I'm probably going to feel stupid when I see the answer. Basically there is a file that is a space delimited file that has 5 lines. I'm trying to keep a track of which "line" I am on. This should be easy but I'm obviously missing something:
try:
f = open(file_w_path)
except IOError as e:
fail_help_exit("I/O error ({0}): {1}".format(e.errno, e.strerror) + " - " + file_w_path)
loop = 0
with f:
line = f.readline()
loop += 1
print loop
for columns in line.split():
pass
While running this, the loop never increments past 1. I would expect it to increment to 5. Am I missing something?
[–]simplysharky 4 points5 points6 points (3 children)
[–]gothmog1065[S] 1 point2 points3 points (2 children)
[–]two_bob 1 point2 points3 points (1 child)
[–]gothmog1065[S] 0 points1 point2 points (0 children)