0

I am writing data from one csv file to other but I want to append a new column to the destination file, Note that the data of the that column stored in a list, This The function I worked on, I want to add the appending step

private void writeDataToCSVDestinationFile(Path csvPath, Path destPath, String colToNormalize) throws IOException, CsvException {
        CSVWriter writer = new CSVWriter(new FileWriter(destPath.toString()));
        CSVReader reader = new CSVReader(new FileReader(csvPath.toString()));
        List<String[]> rows = new ArrayList<>();
          rows= reader.readAll();

    } 

And the data of the column stored in this list:

public static List<BigDecimal> dataAfterNormalization = new ArrayList<>();

Please I need a help to do that

  • You might try to use [this](http://opencsv.sourceforge.net/apidocs/com/opencsv/CSVParserWriter.html#CSVParserWriter-java.io.Writer-com.opencsv.ICSVParser-java.lang.String-) with a subclassed parser that adds an extra column – g00se Jul 07 '21 at 23:31
  • Does this answer your question? [Opencsv + add new column to existing csv](https://stackoverflow.com/questions/26467175/opencsv-add-new-column-to-existing-csv) – Sampath Jul 08 '21 at 01:48

0 Answers0