Ejemplo n.º 1
0
    "Generate the lines of file in reverse order."
    part = ''
    for block in reversed_blocks(file):
        for c in reversed(block):
            if c == '\n' and part:
                yield part[::-1]
                part = ''
            part += c
    if part: yield part[::-1]


def reversed_blocks(file, blocksize=4096):
    "Generate blocks of file's contents in reverse order."
    file.seek(0, os.SEEK_END)
    here = file.tell()
    while 0 < here:
        delta = min(blocksize, here)
        here -= delta
        file.seek(here, os.SEEK_SET)
        yield file.read(delta)


if __name__ == '__main__':
    df = {}  #llections.OrderedDict()
    coinNames = common.getCoinName()
    for coinNm in coinNames:
        coinpath = 't/' + coinNm + '.csv'
        with open(coinpath, 'r') as textfile:
            for row in csv.reader(reversed_lines(textfile)):
                print(', '.join(row))
Ejemplo n.º 2
0
    count = 0

    while is_continue and count < 2:

        history = get_history(sdate, edate, coin)
        history_length = len(history)
        print('history_length', history_length)

        if not history_length:
            is_continue = False
        else:
            count += 1
            history.reverse()

            first_history = history[0]  # 첫 번째 데이터
            last_history = history[history_length - 1]  # 마지막 데이터터

            print(time.ctime(first_history[0] / SECONDS_CONVERT_RATE))
            print(time.ctime(last_history[0] / SECONDS_CONVERT_RATE))

            save(history, coin)

            print('===================')
            edate = sdate
            sdate = edate - get_day_micro_seconds()


if __name__ == '__main__':

    for coin in common.getCoinName():
        run(coin)