I need to use CSVPrinter from Apache's commons in mode when the values are quoted, but the header is not. It looks like there is the only option for quote mode, affecting header and values. Can this be done independently?
CSVFormat format = CSVFormat.DEFAULT.withHeader(new String(){"a", "b"})
.withQuoteMode(QuoteMode.ALL);
CSVPrinter printer = new CSVPrinter(new FileWriter(new File("out.csv")), format);
printer.printRecord("a val", "b val");
printer.printRecord("1", "2");
printer.flush();
printer.close();
gives:
"a", "b"
"a val", "b val"
"1", "2"
But requirement is having this:
a,b
"a val", "b val"
"1", "2"