php - Using a "#" Separator in fgetcsv? -


i used http://php.net/manual/fr/function.fgetcsv.php documentation use fgetcsv function in order import csv file in database (my server doesn't allows me use load data infile sql function).

but csv files contains "#" character line separators , not \n

i don't know how make fgetcsv know line separator...

here code:

    $file = fopen("contenu/bd/test.csv", "r");     fgetcsv($file);     while(($data = fgetcsv($file, 10000, ";")) !== false){         $num = count($data);         ($c=0; $c<$num; $c++){             $col[$c] = $data[$c];         }          ((insert sql))      }     fclose($file); 

thanks lot answers!

but csv files contains "#" character line separators , not \n

then not valid csv file.

i don't know how make fgetcsv know line separator...

no, because not valid line separator. should make valid csv replacing these # \n prior parsing.

*edit**

then either 2 step import -> convert # lfs , use fgetcsv() or can try use str_getcvs() instead, require read , keep whole input file in memory still need break data separate rows (i.e. explode()).


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -