code: def csv_export(self, csv_dest, fieldnames=None, encoding="UTF-8"):
          
          close_on_exit = False
          if isinstance(csv_dest, basestring):
              if PY_3:
                  csv_dest = open(csv_dest, 'w', newline='', encoding=encoding)
              else:
                  csv_dest = open(csv_dest, 'wb')
              close_on_exit = True
          try:
              if fieldnames is None:
                  fieldnames = list(_object_attrnames(self.obs[0]))
              if isinstance(fieldnames, basestring):
                  fieldnames = fieldnames.split()
  
              csv_dest.write(','.join(fieldnames) + NL)
              csvout = csv.DictWriter(csv_dest, fieldnames, extrasaction='ignore', lineterminator=NL)
              if hasattr(self.obs[0], "__dict__"):
                  csvout.writerows(o.__dict__ for o in self.obs)
              else:
                  do_all(csvout.writerow(ODict(starmap(lambda obj, fld: (fld, getattr(obj, fld)),
                                                       zip(repeat(o), fieldnames)))) for o in self.obs)
          finally:
              if close_on_exit:
                  csv_dest.close()
docs: Exports the contents of the table to a CSV-formatted file.
             @param csv_dest: CSV file - if a string is given, the file with that name will be
                 opened, written, and closed; if a file object is given, then that object
                 will be written as-is, and left for the caller to be closed.
             @type csv_dest: string or file
             @param fieldnames: attribute names to be exported; can be given as a single
                 string with space-delimited names, or as a list of attribute names
             @type fieldnames: list of strings
             @param encoding: string (default="UTF-8"); if csv_dest is provided as a string
                 representing an output filename, an encoding argument can be provided (Python 3 only)
             @type encoding: string