I have a file in which lines are separated using a delimeter say .. I want to read this file line by line, where lines should be based on presence of . instead of newline.
One way is:
f = open('file','r')
for line in f.read().strip().split('.'):
#....do some work
f.close()
But this is not memory efficient if my file is too large. Instead of reading a whole file together I want to read it line by line.
open supports a parameter 'newline' but this parameter only takes None, '', '\n', '\r', and '\r\n' as input as mentioned here.
Is there any way to read files line efficiently but based on a pre-specified delimiter?