Description:
        Read from disk a Plackett-Luce dataset.
    Parameters:
        infile: open file object from which to read the dataset

def read_pl_dataset(infile):
    """
    Description:
        Read from disk a Plackett-Luce dataset.
    Parameters:
        infile: open file object from which to read the dataset
    """

    m, n = [int(i) for i in infile.readline().split(',')]
    gamma = np.array([float(f) for f in infile.readline().split(',')])
    if len(gamma) != m:
        infile.close()
        raise ValueError("malformed file: len(gamma) != m")
    votes = []
    i = 0
    for line in infile:
        vote = [int(v) for v in line.split(',')]
        if len(vote) != m:
            infile.close()
            raise ValueError("malformed file: len(vote) != m")
        votes.append(vote)
        i += 1
    infile.close()
    if i != n:
        raise ValueError("malformed file: number of votes != n")
    return (gamma, np.array(votes))