sum static method
Computes the sum of a numeric column.
Implementation
static num sum(Datacat datacat, String columnName) {
int colIndex = datacat.columns.indexOf(columnName);
if (colIndex == -1) {
throw ArgumentError('Column "$columnName" not found.');
}
num total = 0;
for (final row in datacat.rows) {
final value = row[colIndex];
if (value is num) total += value;
}
return total;
}