How to deal with extra space characters while Reading a CSV file?
Posted
by
Ravi Dutt
on Stack Overflow
See other posts from Stack Overflow
or by Ravi Dutt
Published on 2014-06-06T08:51:38Z
Indexed on
2014/06/06
9:25 UTC
Read the original article
Hit count: 211
I am reading a CSV file with CSV Open Source API. as shown below:
Java Code:-->
CSVReader reader = new CSVReader(new FileReader(filePath),'\n');
String[] values;
if((read=(reader.readNext()))!=null)
{
values = (read[0].split(" (?=([^\"]*\"[^\"]*\")*[^\"]*$)",-1)).length;
}
// code ends here
When I read this CSV file line by line and split that line with delimiter. Then after spliting values each value I get contains extra space character after each character in String. Suppose value in file is like "ABC" and I got this after reading from CSV file reader as " A B C " . I used removeAll("\s+","") on each value even after it is not working. Thank You in Advance.
© Stack Overflow or respective owner