I have a gzipped text file that I’m trying to read within PHP (using gzopen/gzgets). The file is somewhat large, around 158,000 lines. The script works fine except when it gets to line 157,237 of the file, it reads in part of the line then acts as if it’s reached EOF. I’m able to unzip the file and confirm the rest of the file does exist. I wrote a simple script to test:
<?php
$handle = gzopen('/path/to/file.gz','r');
while(true) {
echo gzgets($handle,4096);
}
?>
It reads in everything perfectly then suddenly gets to this line and prints:
GUAN XIN 508|R34745|CH|CGO|100|
and nothing else. It just sits there [the not-infinite-loop version exits the while(!gzeof($handle))]
If I gunzip the file and go to that line, I see:
GUAN XIN 508|R34745|CH|CGO|100| | | | |BEGS| | | | |133|19| | | | | | | | | | | | |413669000|1|
So the data is there. Is there some sort of size limitation on the zlib functions that I’m not aware of?
UPDATE: I ran it through a ‘cat -vet’ to look for special characters… nothing.
Updated zlib to 1.2.7. We were running 1.2.3, and “large file” support was apparently added in 1.2.4.