To eliminate blank rows of a .csv fiel to get stored in an arraylist
802235Oct 5 2010 — edited Oct 5 2010I will try my best to explain what my problem is
I have to read a .csv file line by line,split recordsand store it in arraylist.
While reading a line if the row is blank, the row must must be eliminated.
Other non-blank rows' fields must be stored in arraylist.
I counted the total number of rows for checking purpose and it also counts the blank
rows which should not be the case.
When I open the .csv in notepad it replaces blank rows with ,,,,,,,, like this
How can the empty rows can be elimnated to get stored in an arraylist
Since I did not write this code I can give only the logic which was did by the author (not working presently in the company)
String line=br.readline(); // each row of .csv file
while(line!=null && !"".equals(line){
// line is stored in any arraylist
// split the line into tokens using .split(line,-1) and store it
an String array
// store the fields in a bean clas object
}
This works first time after running the application by skipping the blank rows. If I run the application subsequently, this code counts all the blank rows also
Please excuse me if this sounds silly.
Note : I open the .csv file in ms-excel and doing all modifications,insertions,deletions etc