I have the following code written by Michael for finding linecount cheaply but when I run it it gives me an error as AttributeError File object has no attribute 'raw'
Error and I am not sure why this is occurring. Below is the code for reference any help is highly appreciated
from itertools import (takewhile,repeat)
def _make_gen(reader):
b = reader(1024 * 1024)
while b:
yield b
b = reader(1024*1024)
def rawpycount(filename):
f = open(filename, 'rb')
f_gen = _make_gen(f.raw.read)
return sum( buf.count(b'\n') for buf in f_gen )