我当前的代码:
$fileone= fopen("fileone.sql", "r"); //opens file fileone.sql
$fileonewrite = fopen("fileone.rdf", "w"); //this is the file to write to
$fileNum=1;
$i=0;
while (!feof($fileone) ) { //feof = while not end of file
if ($contents = fread($fileonewrite ,53687091200)); //if file is more than 50gb, write to new file (below) .. this doesnt seem to work properly
{ file_put_contents('fileone'.$fileNum.'.rdf',$contents);
$fileNum++;
}
$fileoneRow[] = fgets($fileone); //fgets gets line
$fileoneParts = explode("\t", $fileoneRow[$i]); //explode using tab delimiter
fwrite( " lots of stuff" );
unset($fileoneParts);
}
fclose($fileonetype);
fclose($fileonewrite);
我正在读取大量数据并输出更多数据,创建的文件很容易达到 >200GB。这会导致内存问题。所以我想做的是,当正在写入的文件(例如fileone.rdf)达到50gb 时,我想开始写入filetwo。我的代码 atm 不能很好地工作,因为它似乎输出了数千个空文件。
感谢您阅读我的查询,任何帮助,一如既往地非常感谢。