We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi forum, I had a rather basic question. I am using the in build table class to load this tsv file. Is there a way, I can transform the data which is
2007 12 15 12 2007 12 16 29 2007 12 17 12 2007 12 18 13 2007 12 19 5 2008 1 11 10 2008 1 12 13 2008 1 13 25 2008 1 14 22 2008 1 15 20
So, is there a way, I can add 12 in the second column when the number in first column is 2008..
for(TableRow row : table.rows()) {
int year2 = row.getInt("year");
int month2 = row.getInt("month");
int hour2 = row.getInt("hour");
int count2 = row.getInt("count");
if(year2 == 2008) {
month2 += 12;
println(month2);
}
}
I tried this..
UPDATE: So i was able to do it, but the problem is, I want to store in an array after increasing its value.. Any idea how can I do it? Now I am at:
for(TableRow row : table.rows()) {
int year2 = row.getInt("year");
int month2 = row.getInt("month");
int hour2 = row.getInt("hour");
int count2 = row.getInt("count");
if(year2 == 2008) {
month2 += 12;
// println(month2);
}
for(int i =0; i < table.getRowCount(); i++) {
NewMonth[i] = month2; <---- this for loop is making all values 12
}
}
Answers
Take notice that you can modify a Table or a TableRow by replacing
get
w/set
, like setInt() for example:http://processing.org/reference/TableRow_setInt_.html
And if you prefer to have arrays representing the Table, I've already showed ya in your previous thread:
http://forum.processing.org/two/discussion/3663/table-class-loadtable
You can also create a custom
class
w/ 4 fields to replace the 4 arrays:http://wiki.processing.org/w/From_several_arrays_to_classes
Anyways, here's another example that transfers a Table to a set of arrays again: