I am a beginner to coding and trying to make simple data visualizations using processing. In order to test, i created a csv file where three columns of data are listed where the 2nd and third are numbers. I parsed the columns and tried dividing the 2nd column of numbers with the 3rd. But unfortunately the results are showing zero.
the code is
String tag = "dataset.csv"; String [] rawData;
int [] marks = new int[6]; int [] maxMarks = new int[6];
float [] percentage = new float[6];
void setup() { size(800, 800); smooth();
rawData = loadStrings(tag);
for (int i = 1; i<rawData.length; i++) { String [] thisRow = split(rawData[i], ",");
String subject = thisRow[0]; //// name of the subject marks[i-1] = int(thisRow[1]); //// marks recieved maxMarks [i-1] = int(thisRow[2]); //// maximum marks percentage [i-1] = (marks[i-1]/maxMarks[i-1]); } println(marks); //// prints the numbers 80,45,40,25,30,40 println(maxMarks); //// prints the numbers 100,50,50,50,50,50 println(percentage); //// prints 0.0,0.0,0.0,0.0,0.0,0.0, }
void draw() { }
I wanted the percentage to be calculated and displayed. :(
It would be a great help if someone can help me to sort this out. Many thanks in advance!
Cheers, Yousuf