use of org.knime.base.node.io.csvwriter.FileWriterSettings in project knime-cloud by knime.
the class AbstractAmazonPersonalizeDataUploadNodeModel method writeCSV.
@SuppressWarnings("resource")
private static URI writeCSV(final BufferedDataTable table, final ExecutionContext exec) throws IOException, CanceledExecutionException {
final File createTempDir = FileUtil.createTempFile("KNIME_amazon_personalize_", ".csv");
final BufferedOutputStream tempOut = new BufferedOutputStream(new FileOutputStream(createTempDir));
final FileWriterSettings settings = new FileWriterSettings();
settings.setWriteColumnHeader(true);
try (CSVWriter tableWriter = new CSVWriter(new OutputStreamWriter(tempOut, "UTF-8"), settings)) {
tableWriter.write(table, exec);
}
return createTempDir.toURI();
}
use of org.knime.base.node.io.csvwriter.FileWriterSettings in project knime-cloud by knime.
the class RedshiftCsvWriter method writeData.
@Override
protected FSPath writeData(final ExecutionMonitor exec, final ExecutionParameters<RedshiftLoaderNodeSettings> parameters, final FSPath rootFolder) throws IOException, CanceledExecutionException {
final RedshiftLoaderNodeSettings customSettings = parameters.getCustomSettings();
final FileWriterSettings fileWriterSettings = customSettings.getFileFormatModel().getFileWriterSettings();
final boolean useGzip = !RedshiftLoaderFileFormat.NONE_COMPRESSION.equals(customSettings.getCompressionModel().getStringValue());
final String fileExtension;
if (useGzip) {
fileExtension = FILE_EXTENSION + ".gz";
} else {
fileExtension = FILE_EXTENSION;
}
final FSPath tempFile = createTempFile(rootFolder, fileExtension);
try (OutputStream outputStream = DBFileLoadUtil.createOutputStream(tempFile);
OutputStream os = useGzip ? new GZIPOutputStream(outputStream) : outputStream) {
writeCsv(parameters.getRowInput(), os, fileWriterSettings, exec);
exec.setMessage("Uploading file (no progress available)...");
}
return tempFile;
}
Aggregations