import csv


def read_loss_file(path):
    """Read the given loss csv file and process its data into lists that can be
    plotted by matplotlib.

    Args:
        path (string): The path to the file to be read.

    Returns: A list of lists, one list for each subnetwork containing the loss
             values over time.

    """
    with open(path, 'r') as csvfile:
        reader = csv.reader(csvfile)

        data = []

        for row in reader:
            # Ignore the epoch numbers
            if len(data) == 0:
                data = [[] for _ in row[1:]]

            for i in range(1, len(row)):
                data[i-1].append(float(row[i]))

        return data