code: def _ConvertValueForCsv(self, pql_value):
      
      if 'value' in pql_value:
        field = pql_value['value']
      elif 'values' in pql_value:
        field = pql_value['values']
      else:
        field = None
  
      if field:
        if isinstance(field, list):
          if all(AdManagerClassType(single_field) == AdManagerClassType(field[0])
                 for single_field in field):
            return ','.join([
                '"%s"' % str(self._ConvertValueForCsv(single_field))
                for single_field in field])
          else:
            raise googleads.errors.GoogleAdsValueError(
                'The set value returned contains unsupported mix value types')
  
        class_type = AdManagerClassType(pql_value)
  
        if class_type == 'TextValue':
          s = field.replace('"', '""')
  
          # Encode UTF-8 characters for Python 2 only.
          if sys.version_info.major < 3:
            s = s.encode('UTF8')
          return s
        elif class_type == 'NumberValue':
          return float(field) if '.' in field else int(field)
        elif class_type == 'DateTimeValue':
          return self._ConvertDateTimeToOffset(field)
        elif class_type == 'DateValue':
          return datetime.date(int(field['date']['year']),
                               int(field['date']['month']),
                               int(field['date']['day'])).isoformat()
        else:
          return field
      else:
        return '-'
docs: Sanitizes a field value from a Value object to a CSV suitable format.
  
      Args:
        pql_value: dict a dictionary containing the data for a single field of an
                   entity.
  
      Returns:
        str a CSV writer friendly value formatted by Value.Type.