My data looks like this:
fy|cycle|lea|course|section|description|ssn|uniq_stu_id|grade_1|grade_2|grade_3|grade_4|credit|Date
22|7|6003127|420000|4|BIOLOGY|6435|530|D|D|NULL|NULL|NULL|2012
22|7|6003127|420000|4|BIOLOGY|4328|152|NULL|NULL|B|NULL|NULL|2012
22|7|6003127|421000|1|CHEMISTR|429|1872|B|B|NULL|NULL|NULL|2012
22|7|6003127|422000|1|PHYSICS|1178|950|B|A|NULL|C|NULL|2012
I am interested in the columns grade_1, grade_2, grade_3 and grade_4. I want to pick the latest grade. 1,2,3 and 4 are the semesters, so in the first row, I want to pick D from Grade_2. Similarly, from the last row, I want to pick C from grade_4. In my final output, I want just one column replacing these 4 grade columns showing the final or latest grade along with other information columns.
My approach is as follows:
FileReader fileReader = new FileReader(inputFile);
BufferedReader br = new BufferedReader(fileReader);
while ((line = br.readLine()) != null) {
String[] parts = line.split("\\|");
System.out.println(parts[11].toString());
if (parts[11].toString() != "NULL") {
final_grade = parts[11].toString();
} else if (parts[10].toString() != "NULL") {
final_grade = parts[10].toString();
} else if (parts[9].toString() != "NULL") {
final_grade = parts[9].toString();
} else if (parts[8].toString() != "NULL") {
final_grade = parts[8].toString();
}
else {
final_grade = "N/A";
}
}
With this code, my output gives me all nulls. I am unable to understand where I'm wrong. Can anyone please help?