import csv


def parse_csv(path):
    """Read in the way that dict[algorithm][world_size] --> list"""
    results = dict()
    with open(path) as csvfile:
        iterator = csv.reader(csvfile, delimiter=',')
        for row in iterator:
            print(row)
            algorithm, world_size, object_size, mean, std = row[0].split('_')[-1], int(row[1]), int(row[2]), float(row[3]), float(row[4])
            if algorithm not in results:
                results[algorithm] = {}
            if world_size not in results[algorithm]:
                results[algorithm][world_size] = []
            results[algorithm][world_size].append([object_size, mean, std])
    return results