Rename the file you get from bitcoincharts to btc.csv and run the script.
Code:
<?
$handle = fopen('btc.csv',"r");
$candlesize=600;
$i=0;$j=0;
while (($line = fgetcsv($handle,0,",")) != FALSE) {
$timestamp=$line[0];
if(!isset($nextstamp)){$nextstamp=$timestamp+$candlesize;}
$value=round($line[1],4);
if (($timestamp < $nextstamp)){
$candle[$i]=$value;
$i++;$j++;
}
else
{
if(isset($candle)){
$AVG=array_sum($candle)/count($candle);
$OPEN=$candle[0];
$HIGH=max($candle);
$LOW=min($candle);
$CLOSE=$candle[$i-1];
$TRADES=$i;
}
else {
$AVG=0;
}
print $nextstamp . "," . $OPEN . "," . $HIGH . "," . $LOW . "," . $CLOSE . "," . $TRADES ."\n";
$i=0;
$nextstamp=$nextstamp+$candlesize;
if(isset($candle)){unset($candle);}
}
}
fclose($handle);
?>