1

HELLO printing in a double quote in .tsv file because of '#' like "#HELLO". I want to remove the double quotes when it writes to .tsv

current output -> "#HELLO"

expected output -> #HELLO

try ( CSVPrinter printer = new CSVPrinter(new FileWriter("data.tsv"), CSVFormat.TDF))
{
   printer.printRecord("#HELLO");

}catch (IOException ex) {
    ex.printStackTrace();
}
        
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

2 Answers2

1

You need to adjust format

CSVFormat.Builder.create(CSVFormat.TDF)
    .withQuoteMode(QuoteMode.MINIMAL)
    .build();
talex
  • 17,973
  • 3
  • 29
  • 66
1

I changed the version of CSVCommons to 1.8 and below code is working for me...

CSVPrinter printer = new CSVPrinter(new FileWriter("data.tsv"), CSVFormat.TDF.withHeader("#default1", "default2").withEscape('"').withQuoteMode(QuoteMode.NONE)