Exemple #1
0
def parse_counts():
    parsed_columns = COLUMNS.replace('\n', '')
    measures = json.loads(count_file_loader.load())
    sorted_list = {}
    for measure in measures:
        split = measure.split('-')
        name = split[0]
        time_code = split[1]
        value = measures[measure]
        column_split = parsed_columns.split(',')
        del column_split[0]
        if time_code not in sorted_list:
            sorted_list[time_code] = [None] * len(column_split)
        column_index = column_split.index(name)
        sorted_list[time_code][column_index] = value
    write_counts(sorted_list)
def parse_counts():
    parsed_columns = COLUMNS.replace('\n', '')
    measures = json.loads(count_file_loader.load())
    sorted_list = {}
    for measure in measures:
        split = measure.split('-')
        name = split[0]
        time_code = split[1]
        value = measures[measure]
        column_split = parsed_columns.split(',')
        del column_split[0]
        if time_code not in sorted_list:
            sorted_list[time_code] = [None] * len(column_split)
        column_index = column_split.index(name)
        sorted_list[time_code][column_index] = value
    write_counts(sorted_list)
Exemple #3
0
def update(measure_list):
    measures_count = count_file_loader.load()
    if measures_count:
        measures_count = json.loads(measures_count)
        for measure in measure_list:
            if measure not in measures_count:
                measures_count[measure] = measure_list[measure]
            else:
                measures_count[measure] += measure_list[measure]
        measure_list = measures_count
    filePath = "{0}{1}".format(Config.temp_file_directory, Config.temp_count_file_name)

    for i in measure_list:
        measure_list[i] = round(measure_list[i], 2)

    f = open(filePath,'w')
    f.write(json.dumps(measure_list))
    f.close()