OpenCSV newbie: how to get content from specific cells
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. What am I doing wrong?
public static void main(String[] args) throws IOException,
FileNotFoundException, AimException
{
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] == "CagridId") //customize name
{
CSVReader csvreader = new CSVReader(new
FileReader(csvFilename), ',', '\'', 1);
Integer A = Integer.valueOf(headerLine[i]);
PeserAnnotation1.setCagridId(A);
}
else
{
PeserAnnotation1.setCagridId(0);
}
}
for (int i = 0; i < headerLine.length; i++){
if (headerLine[i] == "PatientComment") //customize name
{
CSVReader csvreader = new CSVReader(new
FileReader(csvFilename), ',', '\'', 1);
PeserAnnotation1.setComment(headerLine[i]);
}
else
{
PeserAnnotation1.setComment("");
}
}
}
No comments:
Post a Comment