In Groovy I am using opencsv to parse the CSV file. my code is not handling value with backslash.
my input file has this value
value1,domain\user,value2
Here is my groovy code.
def filename = 'C:\\Temp\\list.txt'
CSVReader csvReader = new CSVReader(new FileReader(filename))
String[] nextRecord
while ((nextRecord = csvReader.readNext()) != null) {
println nextRecord
}
csvReader.close()
it prints the value with-out backslash for second filed.
[value1, domainuser, value2]
How to handle the backslash value in OpenCSV?
thanks SR
============= Apache Common parser worked.
Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(new FileReader(filename));
for (CSVRecord record : records) {
String f1 = record.get(0);
String f2 = record.get(1);
String f3 = record.get(2);
println f1
println f2
println f3
}