How can I retrieve the original rows' index after performing a query on the dataset?
I'am using JTablesaw as a Dataset library in Java, and I'm looking for a way to get the original rows' index after performing a query/filter on it.
E.g. considering this dataset:
A,B,C
10,5,3
4,7,2
6,9,1
and the below code
Table table = Table.read().file("data.csv");
Table result = table.where(rows -> rows.intColumn("A").isGreaterThanOrEqualTo(6));
With the result table being:
A,B,C
10,5,3
6,9,1
How can I get in output the orginal rows index? E.g.
[0,2]
Filtering creates a new
Tableobject and lacks the option to pull the rows' indices from the original table.One solution is to create a method like below to allow some sort of dynamic iteration over the original table in order to obtain the indices:
collectIndices( table, "A", 6 );returns[0, 2]