Skip to content

Instantly share code, notes, and snippets.

@phoenixperry
Last active August 29, 2015 14:18
Show Gist options
  • Save phoenixperry/02bcb6df908322e17ff4 to your computer and use it in GitHub Desktop.
Save phoenixperry/02bcb6df908322e17ff4 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.Scanner;
String[] stuff;
//this array holds all data bouncing in - I used a file yours will be slightly different
void setup(){
size(200,200);
stuff = loadStrings("data.txt");
}
void draw(){
for(int i=0; i<stuff.length; i++)
{
//split file line by line and get all tabbed data and break at end line
Scanner sc = new Scanner(stuff[i]).useDelimiter("\t|\u0000");
int counter = 0;
//just an example of keeping track - since you know there are 3 (0,1,2) elements in a string
//you can grab each one as data as needed and write that through to whatever variable you are using
while(sc.hasNext()) {
//since we are going line by line you'll need a while loop to get all 3 bits of data out.
println(sc.next());
//get the next bit of data
println(counter);
//print out which val you have
println("--------------------------------");
//toss in a breaker for sanity
counter++;
//up the counter.
}
}
}
@phoenixperry
Copy link
Author

Adelle that does it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment