import csv


def input_performances(name):
    """
    Generates from a .csv file the list of actions and the performance dictionary.

    :param name: Name of the .csv file which must contain on the first line the names
        of the actions, on the second line the names of the criteria and on the
        following lines the performance of each action against each criterion.

    :return A: List of strings corresponding to the names of the actions in the order
        in which they are given in the csv file.

    :return P: Dictionary in which the keys are the names of the actions and the values
        are sub-dictionary where the keys are the criteria and the values are the
        performances.
    """
    A = []
    C = []
    P = {}
    with open(name, 'r', newline='') as P_csv:
        reader = csv.reader(P_csv, delimiter=',')
        line_count = 0
        for row in reader:
            if line_count == 0:
                [A.append(item) for item in row]
            elif line_count == 1:
                [C.append(item) for item in row]
            else:
                perf_A = {}
                for j in range(len(row)):
                    perf_A[C[j]] = float(row[j])
                P[A[line_count-2]] = perf_A
            line_count += 1
    return A, P