简体   繁体   中英

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?

根据JavaDoc代码,您只需要使用当前支持的(不推荐使用)构造函数:

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

I have got the answer in the javadoc

use this:

FileWriter fw= new FileWriter("file.csv");  
CSVWriter cw= new CSVWriter(fw);
cw.writeAll(trade,false); //here false means don't add quotes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM