import csv


def load_angle_offsets(csv_path):
    """Load additive euler angles from CSV file.
    header: joint, i, j, k
    Order of x,y,z values must match order of rotation channels in BVH file. If the order is zxy then i=z, j=x, k=y.
    
    :param csv_path: Path to CSV file containing values.
    :type csv_path: str
    :return: Angle offsets as dictionary.
    :rtype: dict
    """
    angle_offsets = dict()
    try:
        with open(csv_path) as csv_file:
            reader = csv.DictReader(csv_file)
            for row in reader:
                angle_offsets[row['joint']] = tuple(float(row[i]) for i in 'ijk')
    except OSError as e:
        print("ERROR:", e)
    except ValueError as e:
        print("ERROR: Reading angle values failed.", e)
    return angle_offsets