yuliji
3/20/2016 - 8:02 AM

parse candle stick file and output to csv

parse candle stick file and output to csv

import json
from datetime import datetime

with open('kline.out', 'rt') as f:
    data = f.read()
    kline = json.loads(data)
    for dateline, data in kline.iteritems():
        time = datetime.fromtimestamp(float(dateline))
        print "%s,%s,%s,%s,%s,%s,%s" %(dateline, time, data[0], data[1], data[2], data[3], data[4])