I have a file which contains two JSON arrays; one is holding the column names which has 4 values and another array which contains 10,000+ record values.
I am using Symfony and Propel; while using json_decode it throws an allowed memory size exhausted. In my php.ini I have specified the maximum size to 500 MB, but the file executed for 10 seconds and threw the error.
the data file contains
{
"columns_map":["Name","Age","Address","State"],
"rows_map":{"1":["value1","value2","value3","value4"],
"4":["value1","value2","value3","value4"]
"6":["value1","value2","value3","value4"].......upto 10,000 and more records
}
}
in my Symfony page i have this code
$file = "path to the file";
$content = file_get_contents($file);
$array = json_decode($content);
I want to store the file array values into a PHP array and process, and I want to read regardless of the memory limit set in php.ini.
I want to store all the values at once or spit the file and store (e.g. reading the first 1000 records and looping upto the end, but how read the first 1000 records in the rows_map array?).
I solved it by creating a new class of my own with encode and decode functionalities