2

I can read the csv file with the below code,

Reader inRead = new FileReader("testfile.csv");
Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(inRead);
for (CSVRecord record : records) {
    String lastName = record.get("Name");
}

But, I want to append last name with "ABC" and update the same file. is there anyway to do this?

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
sam
  • 31
  • 3
  • 1
    Apache commons CSV doesn't support modifying a file while reading and that is arguably unadvisable. Consider reading the file and then overwrite it with the modified version. If it's important for performance to modify the file while reading have a look at `RandomAccessFile` – Manos Nikolaidis Feb 19 '17 at 17:20
  • Thanks Manos. I'm now using open csv for modification. – sam Feb 21 '17 at 22:27

0 Answers0