Harshit Harshit - 1 year ago 173
Java Question

Including double quotes while writing CSV using apache commons in java

I am using apache commons CSV to write csv files. I want to stick to this library. While I am writing a csv file, in the first column of generated file, it contains double quotes as quote character and other columns are generated as expected.

I really want to get rid of double quotes here. Please find below code for the same.

CSVFormat format = CSVFormat.DEFAULT;
FileWriter fw = new FileWriter("Temp.csv");
CSVPrinter printer = new CSVPrinter(fw, format);

String[] temp = new String[4];

for(int i=0; i<4; i++) {
temp[0] = "#";
temp[0] = "";
temp[1] = "hello" + (i+1);
temp[2] = "";
temp[3] = "test";

Object[] temp1 = temp[]







I don't want a quote character at the beginning of every row. I just want an empty string without quotes, same as in column 3. Can anyone help?

Answer Source

This is known issue. You can vote for it in the apache commons csv issue tracker and hope for the best.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download