has gotten me close to being able to do so, but the data returned in processing is not in a usable format - I just want to have the watts coming in to processing so I can visually represent this data. Right now I'm using the python file as set-up following this tutorial
but it crashes often and the system I've devised to have processing read the csv file output by python is not ideal. Here's the processing program I've come up with to continually update the csv file with wattage info
I am having a problem with using two string arrays to get processing to parse data from a csv file with new data added every 5 seconds. I am able to get one array working to store a full line of data from the csv and then println new data every 5 seconds:
void draw() {
if (index < consumption.length) {
String[] allinfo = split(consumption[index], '\t');
if (allinfo.length == 1) {
float x = float(allinfo[0]);
}
println(allinfo[0]);
index = index + 1;
}
}
But when I try to use a second array to split those lines at the commas and only return the last value in a row, I get an ArrayIndexOutOfBoundsException:1 error message. Is there a better way to use arrays in order to 1. get only the newest string in the csv every 5 seconds and 2. split this string into individual values? I can do both of these things in separate sketches, but not at the same time in one sketch. Any help would be much appreciated! I'm wondering if perhaps I need to use functions instead of just having everything in the void draw? I'm new to processing and programming - I'm still getting used to the concept of arrays and the thing that I am not fully understanding here is the index part of all this, but I think it is necessary in order to get the array to hold only the latest csv value. Here is the sketch that is not working: