This is my code i have cvs file with values and dates in it. I want to be able to get the average of each day and month. So far i am able to get the value for each month but it would require a lot of input to get all the value for each day of the month. Is there a better way to do what i am doing??
i dont want all this global variables also im not sure that with the if statments im achiving my goal properly of getting the month my value is.
Help will be apriciated
float w=0;
float h=0;
int len = 2880;
int[] nums = new int[len];
int sum;
int sum1;
int sum2;
int sum3;
int sum4;
int len1;
int len2;
int len3;
int len4;
void setup(){
Table table = loadTable("indice_2018.CSV","header");
size(8880,400);
background(0);
noLoop();
//Table row = new Table();
for(int i = 0; i<len; i++){
nums[i] = table.getInt(i,"Noroeste PM10");
sum += nums[i];
w = w + .5;
h= h+ 14.4;
String date = table.getString(i,"Fecha");
String d = date.substring(0,2);
String m = date.substring(3,5);
String a = date.substring(6,10);
int y = table.getInt(i,"Noroeste PM10");
int x = table.getInt(i,"Hora");
noStroke();
ellipse(w,y+200,3,3);
if(m.equals("01")){
sum1 += nums[i];
len1 = nums.length;
fill(#FAFF00);
}else if(m.equals("02")) {
sum2 += nums[i];
len2 = nums.length;
fill(#00FF63);
}else if(m.equals("03")) {
sum3 += nums[i];
len3 = nums.length;
fill(#008AFF);
}else if(m.equals("04")) {
sum4 += nums[i];
len4 = nums.length;
fill(#FF002F);
}else{
}
}//for loop ends here
int average1 =sum1/len1;
int average2 =sum2/len2;
int average3 =sum3/len3;
int average4 =sum4/len4;
fill(255);
ellipse(100,average1,10,10);
ellipse(200,average2,10,10);
ellipse(300,average3,10,10);
ellipse(400,average4,10,10);
println(average1);
println(average2);
println(average3);
println(average4);
}