Har*_*hit 9 java csv apache-commons-csv
我正在使用apache commons CSV来编写csv文件.我想坚持这个库.在我编写csv文件时,在生成文件的第一列中,它包含双引号作为引号字符,其他列按预期生成.
我真的想在这里摆脱双引号.请查找以下代码.
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++) {
if(i==1)
temp[0] = "#";
else
temp[0] = "";
temp[1] = "hello" + (i+1);
temp[2] = "";
temp[3] = "test";
Object[] temp1 = temp[]
printer.printRecord(temp1);
}
fw.close();
printer.close();
Run Code Online (Sandbox Code Playgroud)
"",hello1,测试
"#",hello2,测试
"",hello3,测试
"",hello4 ,,测试
我不想在每一行的开头都有引号字符.我只想要一个没有引号的空字符串,与第3列中的相同.任何人都可以帮忙吗?
在lars问题跟踪中提到,尝试将CSVFormat设置为以下,
final CSVFormat csvFileFormat = CSVFormat.DEFAULT.withEscape('\\').withQuoteMode(QuoteMode.NONE);