How to optimize parsing of large csv files?

There is a csv file of the volume 300. It 200 000 lines of the form:

text text; "the text in double quotes; the text in double quotes; the text in double quotes"; text; text
text text; "the text in double quotes; the text in double quotes; the text in double quotes"; text; text; text; text
text text; text; text; "the text in double quotes;the text in double quotes; the text in double quotes"; text; text


Delimiter ; but as the inside cells are also found ; we have to do replace using regular season, the solution found here: 373729

Further, for the processing of the file use the following code:

$handle = fopen($file_save . $name_csv, "r");
 $data_import = array();
 if(empty($handle) === false) {
 while(($data = fgetcsv($handle, 0, ";")) !== FALSE) {
 array_push($data_import, $data);
}
fclose($handle);
 }

the problem is that the script itself takes 1GB operatives. The question is, can I miss a more correct way of parsing a csv file this? The regular season and the parsing posted separately and the amount of consumed memory to the parsing of the file is specified with no work to replace the separator.
July 2nd 19 at 14:09
2 answers
July 2nd 19 at 14:11
Solution
given that then You put it in the database or directly in the DB and then do the logic in SQL. would be orders of magnitude faster and significantly less voraciously to memory
well instead of a gig plus, now up to 80 MB is obtained. the number of dB queries will certainly be great, but it is another option see. to upload the entire list of 200 000 records and to compare them when parsing the csv file again, return to 500+ used memory. or I again do not see the obvious solution of the problem? - itzel.Walter55 commented on July 2nd 19 at 14:14
: I do not understand comments. make LOAD DATA INFILE into a temporary table, then do with it whatever you want. Your poor 200K lines flies in the database in seconds - Arielle15 commented on July 2nd 19 at 14:17
July 2nd 19 at 14:13
Read about generators what Generators (yield) in php? (reference cited, for example, just the first I got and there is just too man showed processing csv)
thanks for the link, a variant similar to the above, but also worthy of attention. - itzel.Walter55 commented on July 2nd 19 at 14:16

Find more questions by tags PHPCSV