Search code examples
javacsvopencsv

remove double quotes from csv while using open csv


Not a duplicate question.

I am using open csv to write csv file.

FileWriter fw= new FileWriter("file.csv");  
CSVWriter cw= new CSVWriter(fw);
cw.writeAll(trade);

but the csv file it is creating contains double quotes on all values.

I found a solution to this in this link

CSVWriter cw= new CSVWriter(fw, CSVWriter.NO_QUOTE_CHARACTER);

but the method is depreciated can anyone suggest any alternate solution?


Solution

  • According to the JavaDoc and the Code you just need to use the currently supported (Not deprecated) constructor:

    CSVWriter cw = new CSVWriter(fw, CSVWriter.DEFAULT_SEPARATOR , CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.DEFAULT_ESCAPE_CHARACTER, CSVWriter.DEFAULT_LINE_END);