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!
How to read a text file in chunks.. 100 lines at a time (\n)
Moderator: General Moderators
Re: How to read a text file in chunks.. 100 lines at a time (\n)
If you guys need a little bit of clarification.
say I have a text file with
Nick
Bob
John
Larry
Ashley
Britney
Tom
Lisa
Joshua
Say I need to process that list 2 lines at a time.
First chunk [Nick,Bob]
Second chunk [John,Larry]
Third chunk [Ashley,Britney]
Does anyone have the slightest idea of how to accomplish that?
say I have a text file with
Nick
Bob
John
Larry
Ashley
Britney
Tom
Lisa
Joshua
Say I need to process that list 2 lines at a time.
First chunk [Nick,Bob]
Second chunk [John,Larry]
Third chunk [Ashley,Britney]
Does anyone have the slightest idea of how to accomplish that?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: How to read a text file in chunks.. 100 lines at a time (\n)
Depends upon what you mean by "process" the lines. What are you doing with them?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.