(Python) Counting lines in a huge (>10GB) file as fast as possible [duplicate]

Ignacio’s answer is correct, but might fail if you have a 32 bit process. But maybe it could be useful to read the file block-wise and then count the \n characters in each block. def blocks(files, size=65536): while True: b = files.read(size) if not b: break yield b with open(“file”, “r”) as f: print sum(bl.count(“\n”) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)