mysql数据库有一字段里的数据含有 "和,在生成csv文件时,会被分割导致错位
当字符含有逗号时,将字符用双引号引起来,那么字符里的逗号将不会被解析;
含有双引号时,可替换为两个双引号。
java编写
int ftpPort = 21;
int capacity = 16;
String remote = fileName;
byte[] bytes = this.produceCSVData(dataList, capacity).getBytes("UTF-8");
FTPClient ftpClient = this.getFtpClient(ftpHost, ftpPort, ftpUserName, ftpPassword);
this.setParameter(ftpClient, ftpPath);
OutputStream out = ftpClient.storeFileStream(remote);
if (out == null) {
throw new RuntimeException("");
}
out.write(bytes);out.close();
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
private String produceCSVData(List
sql编写
select
concat(a,’,’,b,’,’,c,’,’,d,’,’,e,’,’,
case when fis not null then ‘"’||f||’"’ else fend,’,’,g) as col
from tableName



