code: def toCSV(pdl,out=None,write_field_names=True):
      
      import csv
      if out is None:
          file_name = os.path.splitext(pdl.name)[0]+".csv"
          out = open(file_name,"wb")
      fields = ["__id__","__version__"]+pdl.fields
      writer = csv.DictWriter(out,fields)
      # write field names
      if write_field_names:
          writer.writerow(dict([(k,k) for k in fields])) 
      # write values
      writer.writerows(pdl())
      return file_name
docs: Conversion from the PyDbLite Base instance pdl to the file object out
      open for writing in binary mode
      If out is not specified, the field name is the same as the PyDbLite
      file with extension .csv
      If write_field_names is True, field names are written at the top
      of the CSV file