Well if you can’t give the link to your table let’s create a very simple csv table.
Just save this text in a file and give it the name “new.csv”
id,timestamp,name
0,24/12/2020 12:34 pm,Robert
1,24/12/2020 12:35 pm,Noel
2,24/12/2020 12:36 pm,Codestruggles
The following code is a very simple example, and of course, for a real working code, you’ll need a far more complex string search. Modify the timestamp to a time close to testing and add the time you are willing to wait to see the code working. The frameCount part is just to avoid the processor working all the time.
Table table, table1;
int y, m, d, h, mnt, yt, mt, dt, ht, mnt_t;
String str = "Waiting first message";
String id ="";
void setup() {
size(500, 200);
textAlign(CENTER);
textSize(28);
table = loadTable("new.csv", "header");
println(table.getRowCount() + " total rows in table");
for (TableRow row : table.rows()) {
int id = row.getInt("id");
String timestamp = row.getString("timestamp");
String name = row.getString("name");
println(name + " (" + timestamp + ") has an ID of " + id);
}
}
void draw() {
background(255);
fill(0);
if (frameCount % 30 == 0) {
y = year();
m = month();
d = day();
h = hour();
mnt = minute();
for (TableRow row : table.rows()) {
String timestamp = row.getString("timestamp");
// Split the timestamp in its components
dt = int(timestamp.substring(0, 2));
mt = int(timestamp.substring(3, 5));
yt = int(timestamp.substring(6, 10));
ht = int(timestamp.substring(12, 14));
mnt_t = int(timestamp.substring(15, 17));
id = row.getString("id");
if (d == dt && m == mt && y == yt && h == ht && mnt == mnt_t) {
String name = row.getString("name");
str = "Count: "+id+" Name: "+name;
}
}
}
text(str, width/2, height/2);
}