tonelm54
asked on
spitting file into segments, buffer too small
Im trying to read a file by segments, so Ive written the following:-
$this->chunkSize = 1000000, however when I echo out the size of the buffer it is 151 instead 1000000.
Is there a better way to read a file via segments?
What Im trying to do it split a file into segments and process them, as the file is several Gb's in size.
Thanks in advance for any support.
while ($buffer = fgets($handleR, $this->chunkSize)) {
echo strlen($buffer);
$this->chunkSize = 1000000, however when I echo out the size of the buffer it is 151 instead 1000000.
Is there a better way to read a file via segments?
What Im trying to do it split a file into segments and process them, as the file is several Gb's in size.
Thanks in advance for any support.
Please see: http://php.net/manual/en/function.fgets.php where it says,
So basically it looks like the script is reading the first line of the dataset. You may get better results with file_get_contents() since it provides both a starting offset and a maximum length.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.