I am currently working on my first Python project and I need to parse through a 2GB file. I've found out that if I went line by line it would be very very slow... However the buffering method, using:
f = open(filename)
lines = 0
buf_size = 1024 * 1024
read_f = f.read
buf = read_f(buf_size)
while buf:
for line in buf:
#code for string search
print line
buf = read_f(buf_size)
Here the print line doesn't print a "line", it only prints a character at a time per line. So I am having problem doing substring find on it... Please Help!