Created
December 8, 2020 13:39
-
-
Save moscas/85bcd11d4753dc1c4988c06d8a3253e1 to your computer and use it in GitHub Desktop.
Data extractor for IntelliJ which counts the arithmetic mean of the numeric values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Available context bindings: | |
* COLUMNS List<DataColumn> | |
* ROWS Iterable<DataRow> | |
* OUT { append() } | |
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); } | |
* TRANSPOSED Boolean | |
* plus ALL_COLUMNS, TABLE, DIALECT | |
* | |
* where: | |
* DataRow { rowNumber(); first(); last(); data(): List<Object>; value(column): Object } | |
* DataColumn { columnNumber(), name() } | |
*/ | |
def RES = 0G | |
i = 0 | |
ROWS.each { row -> | |
COLUMNS.each { column -> | |
def value = row.value(column) | |
if (value instanceof Number) { | |
RES += value | |
i++ | |
} | |
else if (value.toString().isBigDecimal()) { | |
RES += value.toString().toBigDecimal() | |
i++ | |
} | |
} | |
} | |
RES = RES/i | |
OUT.append(RES.toString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment