I'm trying to get whatever is under a specific header and turn that into a String. I want my code to recognize a header and get the content right under it. Basically get info in a specific cell. What am I doing wrong? I know how to do this by calling specific columns, but now I want to know how to do it by making the code recognize a specific header.
Edit: I updated my code, but still nothing is changed... Help?
ImageAnnotation PeserAnnotation1 = new ImageAnnotation ();
String csvFilename = "C:/Users/Daniela/Documents/ISPY/205_4493_MR1_ACRIN_6657/E25008/peser_data.csv"; //Insert file name and location
CSVReader csvReader = new CSVReader(new FileReader(csvFilename));
String [] headerLine = csvReader.readNext();
//start imageannotation info
for (int i = 0; i < headerLine.length; i++){
if (headerLine[i].equals("PRIMARY_ID")) //customize name
{
CSVReader csvreader = new CSVReader(new FileReader(csvFilename), ',', '\'', 1);
String [] nextLine = csvreader.readNext();
PeserAnnotation1.setPRIMARY_ID(nextLine[i]);
}
else
{
PeserAnnotation1.setPRIMARY_ID("");
}
}
for (int i = 0; i < headerLine.length; i++){
if (headerLine[i].equals("ISPY_ID")) //customize name
{
CSVReader csvreader = new CSVReader(new FileReader(csvFilename), ',', '\'', 1);
String [] nextLine = csvreader.readNext();
PeserAnnotation1.setISPY_ID(nextLine[i]);
}
else
{
PeserAnnotation1.setISPY_ID("");
}
}
The CSV File:
PRIMARY_ID,ISPY_ID, DATE, PE_FTV
205, 1207, 20050819, 8.7508545
Both my code and the CSV file are just samples of the real thing. Currently the code just skips over the "if" and goes straight to the "else".