How to filter data
in
Programming Questions
•
1 year ago
Hey guys, i took data from internet which i am using in my processing project. I took it from the homepage's source, and then i only took out the part i intended to use, after that i removed all the <td> between my data like this.
void setupData(String data) {
String tempString = "";
boolean remove = false;
for (int i = 0; i < data.length(); i++){
char letter = data.charAt(i);
if (letter == '<'){
remove = true;
}else if (letter == '>'){
remove = false;
letter = ' ';
}
if(remove){
letter = ' ';
}
tempString = tempString + letter;
}
println(tempString);
}
String tempString = "";
boolean remove = false;
for (int i = 0; i < data.length(); i++){
char letter = data.charAt(i);
if (letter == '<'){
remove = true;
}else if (letter == '>'){
remove = false;
letter = ' ';
}
if(remove){
letter = ' ';
}
tempString = tempString + letter;
}
println(tempString);
}
So my data now pretty much looks like this :
Country 2008 f 2008 m 2007 f 2007 m 2006 f 2006 m 2000 f 2000 m 1990 f 1990 m 1980 f 1980 m United States 28.33 28.46 28.25 28.38 28.16 28.29 27.53 27.72 26.32 26.61 25.0 25.46 Afghanistan 21.1 20.63 20.98 20.61 20.9 20.59 20.62 20.68 20.73 21.21 20.48 21.42
This is first the year, then countries, counting at which average BMI that country was that specifik year.
Here the thing, this list of countries goes on and on, but i only intend to use 6 countries, im finding it very hard to only use those and use them with the proper variables. any ideas ?
1