-1

I'm trying to delete the contents of a text file till I find a specific string. This was one of the ways I thought was possible.

My doubt is, when you move the pointer to the specific position, what happens to the rest of the data before the pointer? Is it deleted or does it still remain in the memory?

nightfall
  • 21
  • 1
  • 6
  • 2
    Possible duplicate of [this question](https://stackoverflow.com/q/11696472/6632342). Please refer [this](https://docs.python.org/3/tutorial/inputoutput.html) as well. – Venkatesh Wadawadagi Apr 17 '18 at 09:28

1 Answers1

1

When you move a pointer nothing happen. You just tell that the next read will start a the "seeked" position.

If you want to delete part a of file you may have to rewrite it with only the desired content.

Benjamin
  • 3,350
  • 4
  • 24
  • 49
  • Oh OK. What happens to the bytes which are now not accessible? Are they deleted by the OS? – nightfall Apr 17 '18 at 10:39
  • No. they are still there. seek it just to choose where to read the next time. – Benjamin Apr 17 '18 at 10:42
  • Isn't the memory wasted then? If it remains in the memory? Thank you for your time. – nightfall Apr 17 '18 at 10:53
  • It depends how you read your file. You do not have to get it in memory. You can just have a pointer on it. You should read some tutorial on file copy i think – Benjamin Apr 17 '18 at 11:48