Can you post a snippet of your csv file, like the first 20 lines?
You can check this post: max value in an Array - Processing 2.x and 3.x Forum
final int ROW0=0;
final int COL_TIME=0;
final int COL_INTENSITY=1;
Table table;
void setup() {
table=loadTable("data.csv", "header");
table.setColumnType("Time", Table.INT);
table.setColumnType("Intensity", Table.FLOAT);
table.sortReverse("Intensity");
float maxValue = table.getFloat(0, "Intensity");
int time = table.getInt(ROW0, COL_TIME);
float intensity = table.getFloat(ROW0, COL_INTENSITY);
println("Max value is " + intensity +" at time " + time );
}
A small data set:
Time,Intensity
10,0.2
20,0.4
30,0.4
40,0.3
50,0.6
60,0.6
70,0.9
80,0.7
90,0.5
100,0.5
110,0.3
120,0.1
130,0.3
140,0.5
150,0.6
160,0.4
170,0.3
180,0.1
190,0.1
200,0.2
210,0.2
220,0.3
230,0.1
240,0.2
Save the data set inside your data folder in a file called data.csv
. LoadTable()
could probably be better as it implements all the data handling for you. However, you need to become familiar with its functions and it might not work if you need to change the structure of the table. I recommend you check examples provided and accessed through the PDE or check Loading Tabular Data / Examples / Processing.org
Kf