I have a massive .txt
file, and I want to read it one line at a time, and if I find a line which meets a certain condition, I want to go into that file and change the last n
characters of that line only.
The only way I've seen of doing that is to re-write all the lines to a new .txt, while changing the lines you want to change.
This is how I envision my desired logic would look.
for line in infile:
if 'ABC' in line:
infile.#here would come the code to replace characters
I don't think with open()
has this functionality - or does it? Is there a library which does what I describe?
Thanks!