Class SpreadSheetAggregate

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable

    public class SpreadSheetAggregate
    extends AbstractSpreadSheetTransformer
    Aggregates rows (min, max, avg, etc) in a spreadsheet using key columns.
    All numeric columns in the specified aggregrate range (excluding the key columns) get aggregated. For each of the specified aggregates a new column is generated.
    If no key column(s) provided, the complete spreadsheet is used for aggregation.
    Missing cells get ignored.
    COUNT doesn't need any numeric columns.
    Note: A single non-numeric cell makes a column a non-numeric one!

    Input/output:
    - accepts:
       adams.data.spreadsheet.SpreadSheet
    - generates:
       adams.data.spreadsheet.SpreadSheet


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
        min-user-mode: Expert
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: SpreadSheetAggregate
     
    -annotation <adams.core.base.BaseAnnotation> (property: annotations)
        The annotations to attach to this actor.
        default:
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow execution at this level gets stopped in case this
        actor encounters an error; the error gets propagated; useful for critical
        actors.
        default: false
        min-user-mode: Expert
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console; Note: the enclosing
        actor handler must have this enabled as well.
        default: false
        min-user-mode: Expert
     
    -key-columns <adams.data.spreadsheet.SpreadSheetColumnRange> (property: keyColumns)
        The columns to use as keys for identifying rows in the spreadsheets; if
        left empty, all rows are used.
        default:
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last; numeric indices can be enforced by preceding them with '#' (eg '#12'); column names can be surrounded by double quotes.
     
    -aggregate-columns <adams.data.spreadsheet.SpreadSheetColumnRange> (property: aggregateColumns)
        The columns to aggregate (only numeric ones will be used).
        default: first-last
        example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last; numeric indices can be enforced by preceding them with '#' (eg '#12'); column names can be surrounded by double quotes.
     
    -aggregate <COUNT|SUM|MIN|MAX|RANGE|AVERAGE|MEDIAN|STDEV|STDEVP|INTERQUARTILE|QUARTILE25|QUARTILE75> [-aggregate ...] (property: aggregates)
        The aggregates to calculate and introduce as columns.
        default: SUM
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • SpreadSheetAggregate

        public SpreadSheetAggregate()
    • Method Detail

      • setKeyColumns

        public void setKeyColumns​(SpreadSheetColumnRange value)
        Sets the colums that identify a row.
        Parameters:
        value - the range
      • getKeyColumns

        public SpreadSheetColumnRange getKeyColumns()
        Returns the colums that identify a rowx
        Returns:
        the range
      • keyColumnsTipText

        public String keyColumnsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setAggregateColumns

        public void setAggregateColumns​(SpreadSheetColumnRange value)
        Sets the colums that should get aggregated.
        Parameters:
        value - the range
      • getAggregateColumns

        public SpreadSheetColumnRange getAggregateColumns()
        Returns the colums that should get aggregated.
        Returns:
        the range
      • aggregateColumnsTipText

        public String aggregateColumnsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setAggregates

        public void setAggregates​(SpreadSheetAggregate.Aggregate[] value)
        Sets the aggregates to calculate.
        Parameters:
        value - the aggregates
      • aggregatesTipText

        public String aggregatesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • computeAggregates

        protected HashMap<SpreadSheetAggregate.Aggregate,​Number> computeAggregates​(SpreadSheet input,
                                                                                         List<Integer> subset,
                                                                                         int index)
        Computes the aggregates.
        Parameters:
        input - the original sheet
        subset - the subset of rows to use for the computation, null if all rows
        index - the column in the original spreadsheet
        Returns:
        the computed values
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message