docs: def attach(domain, filename):
      '''Attach existing dataset to their harvest remote id before harvesting.
  
      The expected csv file format is the following:
  
      - a column with header "local" and the local IDs or slugs
      - a column with header "remote" and the remote IDs
  
      The delimiter should be ";". columns order
      and extras columns does not matter
      '''
      count = 0
      errors = 0
      with open(filename) as csvfile:
          reader = csv.DictReader(csvfile,
                                  delimiter=b';',
                                  quotechar=b'"')
          for row in reader:
              try:
                  dataset = Dataset.objects.get(id=ObjectId(row['local']))
              except:  # noqa  (Never stop on failure)
                  log.warning('Unable to attach dataset : %s', row['local'])
                  errors += 1
                  continue
  
              # Detach previously attached dataset
              Dataset.objects(**{
                  'extras__harvest:domain': domain,
                  'extras__harvest:remote_id': row['remote']
              }).update(**{
                  'unset__extras__harvest:domain': True,
                  'unset__extras__harvest:remote_id': True
              })
  
              dataset.extras['harvest:domain'] = domain
              dataset.extras['harvest:remote_id'] = row['remote']
              dataset.last_modified = datetime.now()
              dataset.save()
              count += 1
  
      return AttachResult(count, errors)