My Use case is to edit a CSVRecord. I am reading a csv file and need to edit only one column in record on conditional basis. If condition satisfies then need to edit and print to another file else need to print as it is. Any help in how to achieve this. Thanks in Advance.
Reader reader = Files.newBufferedReader(Paths.get(inputFilePath), StandardCharsets.UTF_8);
CSVFormat format = CSVFormat.EXCEL.withFirstRecordAsHeader()
.withIgnoreHeaderCase().withDelimiter(SEPERATOR).withIgnoreSurroundingSpaces()
.withRecordSeparator(NEW_LINE_SEPARATOR)
.withTrim();
CSVParser csvParser = new CSVParser(reader,format);
Something like below
for (CSVRecord csvRecord : csvParser) {
if (someCondition) {
replace "Status" in csvRecord from Not OK to OK
then csvPrinter.printRecord(csvRecord);
} else {
csvPrinter.printRecord(csvRecord);
} }