I'm trying to read lines of some files multiple times in Python.
I'm using this basic way :
with open(name, 'r+') as file:
for line in file:
# Do Something with line
And that's working fine, but if I want to iterate a second time each lines while I'm still with my file open like :
with open(name, 'r+') as file:
for line in file:
# Do Something with line
for line in file:
# Do Something with line, second time
Then it doesn't work and I need to open, then close, then open again my file to make it work.
with open(name, 'r+') as file:
for line in file:
# Do Something with line
with open(name, 'r+') as file:
for line in file:
# Do Something with line
Thanks for answers !