true, CURLOPT_URL => $sendTo, CURLOPT_POSTFIELDS => array( "data" => $data, ), CURLOPT_SAFE_UPLOAD => true, )); $response = curl_exec($ch); curl_close($ch); print "\r\n----"; //$data; print $response; print "----\r\n"; } //Function for sending notifications to pushover, dont worry about it if you dont use it function pushover($title, $msg) { Global $pushover_app,$pushover_user; curl_setopt_array($ch = curl_init(), array( CURLOPT_URL => "https://api.pushover.net/1/messages.json", CURLOPT_POSTFIELDS => array( "token" => $pushover_app, "user" => $pushover_user, "message" => $msg, "title" => $title, ), CURLOPT_SAFE_UPLOAD => true, )); curl_exec($ch); curl_close($ch); return; } //open the csv file now as a read only file so we do not damage the data $file = fopen($csvFile, 'r'); $x = 1; $chunkSize = 300; //change this to how many to send at once, on my local install 5000 worked fine, but test with smaller numbers and work upwards $data = "["; //loops though the file storing each line as the variable $line while(! feof($file)) { if ($x == $chunkSize) { $data = rtrim($data, ','); $data .= ']'; print $data; sendChunk($data); sleep(1); $x = 1; $data = '['; } $line = fgets($file); $line = explode(',', $line); //Check data and do stuff here //Assuming a CSV file of example below // unix time, temperature, humidity // 1483228800, 0, 56 // 1483228810, 0, 56 // 1483228820, 0, 56 // 1483228830, 0, 56 // 1483228840, 0, 56 // 1483228850, 0, 57 // // //$line will now be an array of 3 parts (0 : Unix time, 1: temperature, 2: Humidity) $data .= '['.$line[0].',10,'.$line[1].','.$line[2].'],'; / } fclose($file); //out of the while loop, close the json $data = rtrim($data, ','); $data .= ']'; print $data; sendChunk($data); print "DONE"; //pushover("Stuff Extractor","Done"); //Uncomment if you want to use pushover ?>