Hello, I’m following a tutorial on making a dynamic linegraph whilst using my own data. I’ve come across an error which I’m unable to fix myself and would really appreciate some fresh eyes on this
I know I’m doing something wrong with my array values, but I can’t work out where I’m going wrong.
Main Sketch:
String filename = "Simplified 2019 + 2020 Steps Data.csv";
String[] rawData;
void setup(){
processData();
}
void draw() {
}
void processData(){
rawData = loadStrings(filename);
for(int i = 1; i < rawData.length; i+=9) {
Year y = new Year();
for (int j = 1; j < 9; j++) {
String[] thisRow = split(rawData[i+j], ",");
println(thisRow[1]);
}
}
}
Tab 2 (“Year”)
class Year {
// variables
int level;
int[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int [] steps = new int[9];
// constructor
Year() {
}
// functions
}
And for good measure, here is a screenshot of some of my data (since I can’t upload the CSV file):
Thanks so much for getting back to me! Sorry for being dumb, but could you please show me an example? Is it like this:
if(int i = 1; i < rawData.length; i+=9) {
Year y = new Year();
for (int j = 1; j < 9; j++) {
String[] thisRow = split(rawData[i+j], “,”);
println(thisRow[1]);
}
}
I tried it this way, but it is saying I’ve got an unexpected token, I think I’ve done it wrong haha
Do you know if I could change my array number to fix it at all? My months go up to 9, so I’ve tried making the value “8” since I know an array counts from 0, but that didn’t work either