Keep getting IndexOutOfBoundsException: 948 and cant figure out why
in
Programming Questions
•
2 years ago
//column numbers in data file (cleanT.tsv)
static final int UID = 0;
static final int Y = 1;
static final int X = 2;
static final int LATITUDE = 3;
static final int LONGITUDE = 4;
static final int DATE = 5;
static final int OCCURANCE = 6;
int totalCount; //total number of meetings
Place[] places;
int placeCount;//number of places loaded
//min, max boundary of all points
float minX, maxX;
float minY, maxY;
public void setup(){
readData();
}
void readData(){
String[] lines = loadStrings("cleanT.tsv");
parseInfo(lines[0]);//read the header line
places = new Place[totalCount];
for(int i = 1; i < lines.length; i++){
places[placeCount] = parsePlace(lines[i]); //keeps getting hung up here (ArrayIndexOutOfBoundsException:948)
placeCount++;
}
}
void parseInfo(String line){
String infoString = line.substring(2); //remove the #
String[] infoPieces = split(infoString, ',');
totalCount = int(infoPieces[0]);
minX = float(infoPieces[1]);
maxX = float(infoPieces[2]);
minY = float(infoPieces[3]);
maxY = float(infoPieces[4]);
}
Place parsePlace(String line){
String pieces[] = split(line,TAB);
int uid = int(pieces[UID]);
float y = float(pieces[Y]);
float x = float(pieces[X]);
String date = pieces[DATE];
int occurance = int(pieces[OCCURANCE]);
return new Place(uid, x , y, date, occurance);
}
//This code is essentially copied right out of Visualizing Data the O'Reilly processing book. I am just trying to implement it //with my own data and I keep getting hung up when trying to load the data. Anybody have any suggestions as to what //might be going on here? I have highlighted where it gets hung up
static final int UID = 0;
static final int Y = 1;
static final int X = 2;
static final int LATITUDE = 3;
static final int LONGITUDE = 4;
static final int DATE = 5;
static final int OCCURANCE = 6;
int totalCount; //total number of meetings
Place[] places;
int placeCount;//number of places loaded
//min, max boundary of all points
float minX, maxX;
float minY, maxY;
public void setup(){
readData();
}
void readData(){
String[] lines = loadStrings("cleanT.tsv");
parseInfo(lines[0]);//read the header line
places = new Place[totalCount];
for(int i = 1; i < lines.length; i++){
places[placeCount] = parsePlace(lines[i]); //keeps getting hung up here (ArrayIndexOutOfBoundsException:948)
placeCount++;
}
}
void parseInfo(String line){
String infoString = line.substring(2); //remove the #
String[] infoPieces = split(infoString, ',');
totalCount = int(infoPieces[0]);
minX = float(infoPieces[1]);
maxX = float(infoPieces[2]);
minY = float(infoPieces[3]);
maxY = float(infoPieces[4]);
}
Place parsePlace(String line){
String pieces[] = split(line,TAB);
int uid = int(pieces[UID]);
float y = float(pieces[Y]);
float x = float(pieces[X]);
String date = pieces[DATE];
int occurance = int(pieces[OCCURANCE]);
return new Place(uid, x , y, date, occurance);
}
//This code is essentially copied right out of Visualizing Data the O'Reilly processing book. I am just trying to implement it //with my own data and I keep getting hung up when trying to load the data. Anybody have any suggestions as to what //might be going on here? I have highlighted where it gets hung up
1