Class FeatureCSVWriter

Object
FeatureCSVWriter

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

    • NUMBER_DECIMAL_PLACES

      public static final int NUMBER_DECIMAL_PLACES
      The number of decimal places to use for double values, unless visuallyShortened==true.
      See Also:
  • 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, Outputter outputter, boolean visuallyShortenedDecimals) throws 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:
      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.