I'm trying to process a large(150MB+) JavaScript array from a CSV file.
Here is what the array looks like:
var results = [
{"requestId":"1","responseId":"1","time":"11","opacity":"0.6"}
,
{"requestId":"1","responseId":"2","time":"12","opacity":"0.7"}
,
{"requestId":"1","responseId":"3","time":"13","opacity":"0.8"}
,
{"requestId":"1","responseId":"4","time":"14","opacity":"0.9"}
,
{"requestId":"1","responseId":"5","time":"15","opacity":"0.1"}
....
];
There are about 100,000 lines. I need to take each of the values from each of the array elements.
For instance, I need to take 1, 1, 11 and 0.6 from "requestId", "responseId", "time" and "opacity" respectively.
I've tried to use *file_get_contents* (failed, couldn't read the file, it is too big), and file stream, also the following code to read, but i don't know how to extract the numbers using PHP. Thanks so much for your help. Is there anyway that I can convert this into PHP array or JSON? I like to process the numbers as quick as possible though...
$fh = fopen($cachedFile, 'r');
$Data = fread($fh, filesize($cachedFile));
fclose($fh);
echo "<pre>";
echo $Data;
echo "</pre>";
jsonlikeMongoDBjsontomysqlbut not by default see karlssonondatabases.blogspot.se/2012/07/…