Link to home
Start Free TrialLog in
Avatar of PearlJamFanatic
PearlJamFanatic

asked on

opencsv CSVReader does not read \ (backslash)

I am reading CSV file using the following code. I use OpenCSV library.

csvReaderList.add(new CSVReader(new FileReader(csvFileNames.get(2))));
while ((nextLineCsv1 = csvReaderList.get(0).readNext()) != null&&(nextLineCsv2= csvReaderList.get(1).readNext()) != null&&(nextLineCsv3 = csvReaderList.get(2).readNext()) != null) {
		    	ArrayList<String[]> rowFromAllThreeCsv=new ArrayList<String[]>();
		    	rowFromAllThreeCsv.add(nextLineCsv1);
		    	rowFromAllThreeCsv.add(nextLineCsv2);
		    	rowFromAllThreeCsv.add(nextLineCsv3);
}

Open in new window


Below you can see the exact csv file line. The first one succeeds it has \ followed by space. The next one fails it has only \. When read the first one returns an array of 12 cells and the next one has only 6.

The below works
"25-Jan-2008 08:46:00","datamirror","","50545","#PGAAGIN    ","1020360224","\                             ","0","TRSYS","CMPLACTS    ","",""


The below fails
"25-Jan-2008 08:46:00","datamirror","","50545","#PGAAGIN","1020360224","\","0","TRSYS","CMPLACTS","",""

I think i need to initilise the CSVReader wih the right constructor. Please help.
Avatar of PearlJamFanatic
PearlJamFanatic

ASKER

The problem could be with special characters (something that looks like space character). The \ appears in the line that works. Its \ followed by the special characters that didn't work.
ASKER CERTIFIED SOLUTION
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial