code: def create_settings(self):
      self.delimiter = CustomChoice(
          "Select the column delimiter",
          DELIMITERS,
          doc="""\
  Select the delimiter to use, i.e., the character that separates columns in a file. The
  two default choices are tab and comma, but you can type in any single character delimiter
  you prefer. Be sure that the delimiter you choose is not a character that is present
  within your data (for example, in file names).""",
      )
  
      self.directory = Directory(
          "Output file location",
          dir_choices=[
              ABSOLUTE_FOLDER_NAME,
              DEFAULT_OUTPUT_FOLDER_NAME,
              DEFAULT_OUTPUT_SUBFOLDER_NAME,
              DEFAULT_INPUT_FOLDER_NAME,
              DEFAULT_INPUT_SUBFOLDER_NAME,
          ],
          doc="""\
  This setting lets you choose the folder for the output files. {folder_choice}
  
  {metadata_help}
  """.format(
              folder_choice=IO_FOLDER_CHOICE_HELP_TEXT,
              metadata_help=IO_WITH_METADATA_HELP_TEXT,
          ),
      )
      self.directory.dir_choice = DEFAULT_OUTPUT_FOLDER_NAME
  
      self.wants_prefix = Binary(
          "Add a prefix to file names?",
          True,
          doc="""\
  This setting lets you choose whether or not to add a prefix to each of
  the .CSV filenames produced by **ExportToSpreadsheet**. A prefix may be
  useful if you use the same directory for the results of more than one
  pipeline; you can specify a different prefix in each pipeline. Select
  *"Yes"* to add a prefix to each file name (e.g., “MyExpt\_Images.csv”).
  Select *"No"* to use filenames without prefixes (e.g., “Images.csv”).
              """
          % globals(),
      )
  
      self.prefix = Text(
          "Filename prefix",
          "MyExpt_",
          doc="""\
  (*Used only if “Add a prefix to file names?” is "Yes"*)
  
  The text you enter here is prepended to the names of each file produced by
  **ExportToSpreadsheet**.
              """
          % globals(),
      )
  
      self.wants_overwrite_without_warning = Binary(
          "Overwrite existing files without warning?",
          False,
          doc="""\
  This setting either prevents or allows overwriting of old .CSV files by
  **ExportToSpreadsheet** without confirmation. Select *"Yes"* to
  overwrite without warning any .CSV file that already exists. Select
  *"No"* to prompt before overwriting when running CellProfiler in the
  GUI and to fail when running headless."""
          % globals(),
      )
  
      self.add_metadata = Binary(
          "Add image metadata columns to your object data file?",
          False,
          doc="""\
  “Image\_Metadata\_” columns are normally exported in the Image data
  file, but if you select *"Yes"*, they will also be exported with the
  Object data file(s)."""
          % globals(),
      )
  
      self.add_filepath = Binary(
          "Add image file and folder names to your object data file?",
          False,
          doc="""\
  “Image\_PathName\_” and “Image\_FileName\_” columns are normally
  exported in the Image data file, but if you select *"Yes"*, they will also
  be exported with the Object data file(s)."""
          % globals(),
      )
  
      self.nan_representation = Choice(
          "Representation of Nan/Inf",
          [NANS_AS_NANS, NANS_AS_NULLS],
          doc="""\
  This setting controls the output for numeric fields if the calculated
  value is infinite (*Inf*) or undefined (*NaN*). CellProfiler will
  produce Inf or NaN values under certain rare circumstances, for instance
  when calculating the mean intensity of an object within a masked region
  of an image.
  
  -  *%(NANS_AS_NULLS)s:* Output these values as empty fields.
  -  *%(NANS_AS_NANS)s:* Output them as the strings “NaN”, “Inf” or
     “-Inf”."""
          % globals(),
      )
  
      self.pick_columns = Binary(
          "Select the measurements to export",
          False,
          doc="""\
  Select *{YES}* to provide a button that allows you to select which
  measurements you want to export. This is useful if you know exactly what
  measurements you want included in the final spreadsheet(s) and additional
  measurements would be a nuisance.
  
  Alternatively, this option can be helpful for viewing spreadsheets in
  programs which limit the number of rows and columns.
  """.format(
              **{"YES": "Yes"}
          ),
      )
  
      self.columns = MeasurementMultiChoice(
          "Press button to select measurements",
          doc="""\
  *(Used only when selecting the columns of measurements to export)*
  
  This setting controls the columns to be exported. Press the button and
  check the measurements or categories to export.""",
      )
  
      self.wants_aggregate_means = Binary(
          "Calculate the per-image mean values for object measurements?",
          False,
          doc="""\
  Select *"Yes"* for **ExportToSpreadsheet** to calculate population
  statistics over all the objects in each image and save that value as an
  aggregate measurement in the Image file. For instance, if you are
  measuring the area of the Nuclei objects and you check the box for this
  option, **ExportToSpreadsheet** will create a column in the Image file
  called “Mean\_Nuclei\_AreaShape\_Area”. Note that this setting can
  generate a very large number of columns of data.
  
  However, if you chose to select the specific measurements to
  export, the aggregate statistics will only be computed for the selected
  per-object measurements."""
          % globals(),
      )
  
      self.wants_aggregate_medians = Binary(
          "Calculate the per-image median values for object measurements?",
          False,
          doc="""\
  Select *"Yes"* for **ExportToSpreadsheet** to calculate population
  statistics over all the objects in each image and save that value as an
  aggregate measurement in the Image file. For instance, if you are
  measuring the area of the Nuclei objects and you check the box for this
  option, **ExportToSpreadsheet** will create a column in the Image file
  called “Median\_Nuclei\_AreaShape\_Area”. Note that this setting can
  generate a very large number of columns of data.
  
  However, if you chose to select the specific measurements to
  export, the aggregate statistics will only be computed for the selected
  per-object measurements."""
          % globals(),
      )
  
      self.wants_aggregate_std = Binary(
          "Calculate the per-image standard deviation values for object measurements?",
          False,
          doc="""\
  Select *"Yes"* for **ExportToSpreadsheet** to calculate population
  statistics over all the objects in each image and save that value as an
  aggregate measurement in the Image file. For instance, if you are
  measuring the area of the Nuclei objects and you check the box for this
  option, **ExportToSpreadsheet** will create a column in the Image file
  called “StDev\_Nuclei\_AreaShape\_Area”. Note that this setting can
  generate a very large number of columns of data.
  
  However, if you chose to select the specific measurements to
  export, the aggregate statistics will only be computed for the selected
  per-object measurements."""
          % globals(),
      )
  
      self.wants_genepattern_file = Binary(
          "Create a GenePattern GCT file?",
          False,
          doc="""\
  Select *"Yes"* to create a GCT file compatible with `GenePattern`_.
  The GCT file format is a tab-delimited text file format designed for
  gene expression datasets; the specifics of the format are described
  `here`_. By converting your measurements into a GCT file, you can make
  use of GenePattern’s data visualization and clustering methods.
  
  Each row in the GCT file represents (ordinarily) a gene and each column
  represents a sample (in this case, a per-image set of measurements). In
  addition to any other spreadsheets desired, enabling this option will
  produce a GCT file with the extension .gct, prepended with the text
  selection above. If per-image aggregate measurements are requested
  above, those measurements are included in the GCT file as well.
  
  .. _GenePattern: http://www.broadinstitute.org/cancer/software/genepattern/
  .. _here: http://software.broadinstitute.org/cancer/software/genepattern/file-formats-guide"""
          % globals(),
      )
  
      self.how_to_specify_gene_name = Choice(
          "Select source of sample row name",
          GP_NAME_OPTIONS,
          GP_NAME_METADATA,
          doc="""\
  *(Used only if a GenePattern file is requested)*
  
  The first column of the GCT file is the unique identifier for each
  sample, which is ordinarily the gene name. This information may be
  specified in one of two ways:
  
  -  *Metadata:* If you used the **Metadata** modules to add metadata to
     your images, you may specify a metadata tag that corresponds to the
     identifier for this column.
  -  *Image filename:* If the gene name is not available, the image
     filename can be used as a surrogate identifier.
  
  {meta_help}
  """.format(
              meta_help=USING_METADATA_HELP_REF
          ),
      )
  
      self.gene_name_column = Measurement(
          "Select the metadata to use as the identifier",
          lambda: IMAGE,
          doc="""\
  *(Used only if a GenePattern file is requested and metadata is used to
  name each row)*
  
  Choose the measurement that corresponds to the identifier, such as
  metadata from the **Metadata** module. {meta_help}""".format(
              meta_help=USING_METADATA_HELP_REF
          ),
      )
  
      self.use_which_image_for_gene_name = ImageSubscriber(
          "Select the image to use as the identifier",
          "None",
          doc="""\
  *(Used only if a GenePattern file is requested and image filename is
  used to name each row)*
  
  Select which image whose filename will be used to identify each sample row.""",
      )
  
      self.wants_everything = Binary(
          "Export all measurement types?",
          True,
          doc="""\
  Select *"Yes"* to export every category of measurement.
  **ExportToSpreadsheet** will create one data file for each object
  produced in the pipeline, as well as per-image, per-experiment and
  object relationships, if relevant. See *{naming_help}*
  for more details on the various measurement types. The module will use
  the object name as the file name, optionally prepending the output file
  name if specified above.
  
  Select *"No"* if you want to do either (or both) of two things:
  
  -  Specify which objects should be exported;
  -  Override the automatic nomenclature of the exported files.""".format(
              naming_help=MEASUREMENT_NAMING_HELP
          ),
      )
  
      self.object_groups = []
      self.add_object_group()
      self.add_button = DoSomething(
          "", "Add another data set", self.add_object_group
      )
  
imports: import base64
  import csv
  import logging
  import os
  import numpy
  from cellprofiler_core.constants.image import C_MD5_DIGEST, C_SCALING, C_HEIGHT, C_WIDTH
  from cellprofiler_core.constants.measurement import EXPERIMENT, IMAGE, AGG_MEAN, AGG_MEDIAN, AGG_STD_DEV, C_URL, C_PATH_NAME, C_FILE_NAME, NEIGHBORS, R_FIRST_IMAGE_NUMBER, R_SECOND_IMAGE_NUMBER, R_FIRST_OBJECT_NUMBER, R_SECOND_OBJECT_NUMBER
  from cellprofiler_core.constants.module import IO_FOLDER_CHOICE_HELP_TEXT, IO_WITH_METADATA_HELP_TEXT, USING_METADATA_HELP_REF, USING_METADATA_TAGS_REF
  from cellprofiler_core.constants.pipeline import EXIT_STATUS
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import ABSOLUTE_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_SUBFOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_SUBFOLDER_NAME
  from cellprofiler_core.preferences import get_headless
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import Divider
  from cellprofiler_core.setting import Measurement
  from cellprofiler_core.setting import SettingsGroup
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import CustomChoice, Choice
  from cellprofiler_core.setting.do_something import DoSomething, RemoveSettingButton
  from cellprofiler_core.setting.multichoice import MeasurementMultiChoice
  from cellprofiler_core.setting.subscriber import ImageSubscriber, LabelSubscriber
  from cellprofiler_core.setting.text import Directory, Text
  from cellprofiler_core.utilities.core.modules.load_data import is_file_name_feature, is_path_name_feature
  from cellprofiler_core.utilities.measurement import find_metadata_tokens, get_agg_measurement_name
  from cellprofiler.gui.help.content import MEASUREMENT_NAMING_HELP
label_desc: Use image node_id 1 for calling the ExportToSpreadsheet obj's underlying member method code with example usage: obj.create_settings() without return types