本文介绍了writeAll(ResultSet res,Boolean b)opencsv方法在数据周围添加双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此函数写入csv文件时,所有数据都嵌入双引号中。

When I use this function to write to a csv file all the data is embedded in double quotes.

有没有办法写入csv文件而没有双引用?

Is there a way to write to csv file without the double quotes?

CSVWriter writer = new CSVWriter(new FileWriter(table+".csv"), '\t');
            writer.writeAll(rset, true);
            writer.close();

该文件包含表格中的数据

the file contains data in the form

"EMPNO" "ENAME" "JOB"   "MGR"   "HIREDATE"  "SAL"   "COMM"  "DEPTNO"    "TAG"   "LOOKUP"
"7369"  "SMITH" "CLERK" "7902"  "17-Dec-1980"   "800"   "2" "20"    "E" "1"
"7499"  "ALLEN" "SALESMAN"  "7698"  "20-Feb-1981"   "1600"  "2" "30"    "E" "2"
"7521"  "WARD"  "SALESMAN"  "7698"  "22-Feb-1981"   "1250"  "2" "30"    "E" "3"
"7566"  "JONES" "MANAGER"   "7839"  "02-Apr-1981"   "2975"  "2" "20"    "E" "2"


推荐答案

CSVWriter writer = new CSVWriter(new FileWriter(table+".csv"), '\t', CSVWriter.NO_QUOTE_CHARACTER);
            writer.writeAll(rset, true);
            writer.close();

参考:

这篇关于writeAll(ResultSet res,Boolean b)opencsv方法在数据周围添加双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 14:54