0

I'm opening a text file and doing a:

f.seek(mid) where mid= (0+f.seek(0,2))//2

Now I want to check if the read pointer is at the starting of a new line or not?

Based on that I discard f.readline() if pointer is not at the start and read a new line.

kartheek7895
  • 341
  • 1
  • 12

1 Answers1

0

One trivial solution would be to do f.seek(mid-1) and check if f.read(1) == "\n" or not.

kartheek7895
  • 341
  • 1
  • 12