Hi! im on a sketch in which i have some classes and one of then should take a .csv file and create some lists.
ive set a global string to receive the selectInput() result and asked the class to generate the table using the string as a parameter. im receiving a NullPointerException.
my guess is that loadTable(filename, “header”) is looking for the file inside the data folder but as its receiving a whole path wherever the user chose a file from (like “c:\users\name\file.csv”), it wont work.
heres a sample of the code:
String pathSelection;
tracker myTracker;
void setup(){
//size(1900, 1000);
myTracker = new tracker();
myTracker.getFile();
}
void draw(){}
class tracker{
//tracker class constructor goes here and some other parameters
void getList(){
selectInput("Select a encounter to load", "fileSelected");
Table eventTable = loadTable(pathSelection, "header");
for(TableRow row : eventTable.rows()){
//variables are created here to receive the rows from the csv file and process whats needed.
}
}
}
so, if its the way im guessing, how can i implement a way to the user select a file from anywhere and it generates a table?
@Chrisir: yeah, i forgot to paste the function. theres one, i copied it from the reference.
@mnse: it worked just fine, thank you! im new to programming and processing helps a lot. im yet to understand “public”, “static” and other types of function declarations; im guessing thats what went wrong, but it will be a task for another day.
now i got to transform my cvs into nice “artistic-like” graphics with motion and other stuff.
thank you so much you both for your time and your help!