import csv


def LoadVNSIM(nsim_csv):
  """Returns dictionary with degraded file key and mean nsim value.

  The CSV should have three values: reference path, degraded path, nsim value

  Args:
    nsim_csv: Path to CSV file with NSIM values, format described above.

  Returns:
    Dictionary with degraded file key and NSIM value.
  """
  nsim_dict = {}

  with open(nsim_csv, 'r') as csvfile:
    nsim_reader = csv.reader(csvfile)
    for row in nsim_reader:
      # Skip header
      if row[2] == 'vnsim':
          continue
      # Keep the degraded file without the directory info as key.
      # This will match what the mos dictionary has.
      deg_file = row[1].split('/')[-1]
      nsim_dict[deg_file] = row[2]
  return nsim_dict