Read in php a geant csv

Good morning every one,

I have to import datas from a geant csv of 3Go

=> I can not open it fully in one time too big.

I don’t know how to extract by small package, for example I want to take from the character or line 1000000 to 1001000
I have tried something like this but it do not work

$filename = “1688FULL.csv”;
$handle = fopen($filename, “r”);
$contents = fread($handle, 1000000,1000);
fclose($handle);
echo $contents;

How to read 10.000 characters from the character 1000000 ?
Thank you for your help
Alban

What are you doing with the file? You might be able to import it to SQL using LOAD DATA INFILE

If not what you could do is use prepared statements (they are faster when ran sequentially), read/insert one line at the time and do it in rounds of 10 000 (?) queries a piece. If you log the round index on completion you can easily pick up where you left off if something goes south.

Sponsor our Newsletter | Privacy Policy | Terms of Service