How to read a text file in chunks.. 100 lines at a time (\n)
Posted: Thu Feb 11, 2010 1:03 am
I have tried numerous different codes and I keep failing at doing this.
Say I have a large text file, each line contains valuable data..so I can't just do a fgets and set a certain amount of data to read because I am not sure on each lines length so some times the data would get cut off and not processed correctly so I need to read it line by line.
The problem is processing each piece of data line by line is way to slow. So i thought if I read say 100 lines at once as a chunk and then processed that chunk of 100 items of data it would speed things up by a lot!
Please some one help me!
Say I have a large text file, each line contains valuable data..so I can't just do a fgets and set a certain amount of data to read because I am not sure on each lines length so some times the data would get cut off and not processed correctly so I need to read it line by line.
The problem is processing each piece of data line by line is way to slow. So i thought if I read say 100 lines at once as a chunk and then processed that chunk of 100 items of data it would speed things up by a lot!
Please some one help me!