import csv


def snp2dict(snpfile):
    """Get settings of dict from .snp file exported from save&restore app.

    Parameters
    ----------
    snpfile : str
        Filename of snp file exported from save&restore app.

    Returns
    -------
    r : dict
        Dict of pairs of PV name and setpoint value.
    """
    with open(snpfile, 'r') as fp:
        csv_data = csv.reader(fp, delimiter=',', skipinitialspace=True)
        next(csv_data)
        header = next(csv_data)
        ipv, ival = header.index('PV'), header.index('VALUE')
        settings = {line[ipv]: line[ival] for line in csv_data if line}
    return settings