Skip to content

Instantly share code, notes, and snippets.

@mrmemmo
Created March 12, 2019 15:09
Show Gist options
  • Save mrmemmo/50c850dae8bf6434d92983ade36b147f to your computer and use it in GitHub Desktop.
Save mrmemmo/50c850dae8bf6434d92983ade36b147f to your computer and use it in GitHub Desktop.
String[] lines;
ArrayList<String> pnames = new ArrayList<String>();
ArrayList<Integer> count = new ArrayList<Integer>();
int x = 0;
int y = 380;
int size = 1;
String name = "player";
int amount = 1;
void setup(){
size(700,400);
read();
}
void draw(){
background(5);
textSize(32);
text(name + " " + amount, 10, 30);
}
public void read(){
lines = loadStrings("http://172.16.36.226/nba.csv");
println("There are " + lines.length + " lines.");
//printArray(lines);
for(int i=0; i<lines.length; i++){//look at each line
String[] s1 = lines[i].split(",");
//players name s1[1]
boolean found = false;
for(int j=0; j<pnames.size(); j++){//is it already in
//the pname arraylist?
if(pnames.get(j).equals(s1[1])){//if it is
count.set(j,count.get(j)+1);//update the count list
found = true;
}
}//
if(found==false){//if it's not add it
pnames.add(s1[1]);
count.add(1);
}
}//end of for loop
//remove if not more than once
for(int j=count.size()-1; j>=0; j--){
if(count.get(j)<10){
count.remove(j);
pnames.remove(j);
}
}
println(count.size());
}//end of read function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment