Class FeatureCSVWriter

Object
org.anchoranalysis.feature.io.csv.FeatureCSVWriter

public class FeatureCSVWriter
extends Object
Writes the results of feature-calculations as a CSV file.
Author:
Owen Feehan
  • Field Details

  • Constructor Details

    • FeatureCSVWriter

      public FeatureCSVWriter​(CSVWriter writer, boolean visuallyShortenedDecimals)
      Creates for a CSVWriter.
      Parameters:
      writer - underlying CSV writer, which if null, it means the writer is disabled.
      visuallyShortenedDecimals - when true double values are printed to be as short as possible without losing precision, otherwse with NUMBER_DECIMAL_PLACES.
  • Method Details

    • create

      public static Optional<FeatureCSVWriter> create​(FeatureCSVMetadata metadata, org.anchoranalysis.io.output.outputter.Outputter outputter, boolean visuallyShortenedDecimals) throws org.anchoranalysis.io.output.error.OutputWriteFailedException
      Maybe creates a FeatureCSVWriter depending if the output is allowed.
      Parameters:
      metadata - metadata needed for writing the feature-results.
      outputter - determines if the output is allowed.
      visuallyShortenedDecimals - when true double values are printed to be as short as possible without losing precision.
      Returns:
      a write, if it is allowed.
      Throws:
      org.anchoranalysis.io.output.error.OutputWriteFailedException - if the CSV file cannot be created successfully.
    • addRow

      public void addRow​(LabelledResultsVector results)
      Directly adds a row of feature-values.
      Parameters:
      results - results for the row, along with corresponding labels.
    • addRow

      public void addRow​(List<TypedValue> values)
      Directly adds a row in the form of typed-values.
      Parameters:
      values - a list of typed-values corresponding to a row in a CSV file.
    • close

      public void close()
      Closes any open file-handles.

      This operation should always be called once at the end of writing.