提交 4949027d 编写于 作者: J jurgen

CSV exporter quote char config

上级 99f626c2
MongoDB driver (3.x)
Folders colors customization.
DB toolbar/menu visibility config in Eclipse mode
MacOS test
Eclipse Mars update
OpenSUSE test (UI is broken)
......@@ -11,7 +9,6 @@ Objects cache. Allow to load single object without entire cache loading (for tab
Remove QMDB warnings from main Error Log
Delete button in doc editors. Disable all RSV actions when in editor (inline/over)
Export to CSV - configure quote character
Split core and ui on different plugins
DBeaver features usage model
Vertica keywords
......
......@@ -2365,6 +2365,7 @@
<property id="delimiter" label="%dataTransfer.processor.csv.property.delimiter.name" type="string" description="%dataTransfer.processor.csv.property.delimiter.description" defaultValue="," required="true"/>
<property id="header" label="%dataTransfer.processor.csv.property.header.name" type="string" description="%dataTransfer.processor.csv.property.header.description" defaultValue="top" required="true" validValues="none,top,bottom,both"/>
<property id="escape" label="%dataTransfer.processor.csv.property.escape.name" type="string" description="%dataTransfer.processor.csv.property.escape.description" defaultValue="quotes" required="true" validValues="quotes,escape"/>
<property id="quoteChar" label="%dataTransfer.processor.csv.property.quoteChar.name" type="string" description="%dataTransfer.processor.csv.property.quoteChar.description" defaultValue="&quot;" required="false"/>
</propertyGroup>
</processor>
<processor
......
......@@ -18,6 +18,7 @@
package org.jkiss.dbeaver.tools.transfer.stream.impl;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.data.DBDContent;
......@@ -41,6 +42,7 @@ public class DataExporterCSV extends StreamExporterAbstract {
private static final String PROP_DELIMITER = "delimiter";
private static final String PROP_HEADER = "header";
private static final String PROP_QUOTE_CHAR = "quoteChar";
public static final char DEF_DELIMITER = ',';
enum HeaderPosition {
......@@ -75,6 +77,10 @@ public class DataExporterCSV extends StreamExporterAbstract {
} else {
delimiter = DEF_DELIMITER;
}
String quoteStr = String.valueOf(site.getProperties().get(PROP_QUOTE_CHAR));
if (!CommonUtils.isEmpty(quoteStr)) {
quoteChar = quoteStr.charAt(0);
}
out = site.getWriter();
rowDelimiter = GeneralUtils.getDefaultLineSeparator();
try {
......@@ -129,7 +135,9 @@ public class DataExporterCSV extends StreamExporterAbstract {
DBDContent content = (DBDContent)row[i];
try {
DBDContentStorage cs = content.getContents(monitor);
if (ContentUtils.isTextContent(content)) {
if (cs == null) {
writeCellValue(DBConstants.NULL_VALUE_LABEL, false);
} else if (ContentUtils.isTextContent(content)) {
writeCellValue(cs.getContentReader());
} else {
getSite().writeBinaryData(cs.getContentStream(), cs.getContentLength());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册