What is the best way to parse this cross domain csv file to an array?
Example data:
2015-03-26 01:00; 1,428; 39,513
2015-03-26 02:00; 1,425; 39,294
2015-03-26 03:00; 1,422; 39,076
2015-03-26 04:00; 1,421; 39,004
2015-03-26 05:00; 1,416; 38,642
2015-03-26 06:00; 1,416; 38,642
2015-03-26 07:00; 1,416; 38,642
2015-03-26 08:00; 1,416; 38,642
I tried something like this:
$file = fopen("http://somedomain.com/data.csv", "r");
while (($buffer = fgets($file)) !== false) {
$fields = explode(";", $buffer);
print_r(fgetcsv($file));
}
fclose($file);
But it still splits the data at the comma, not semicolon. I'd be happy for any suggestions!
;to get it to split by a semi-colon.print_r($fields)and you will see the actual result of splitting at your specified delimiter.