use of org.supercsv.io.CsvListWriter in project waltz by khartec.
the class ReportGridExtractor method mkCSVReport.
private byte[] mkCSVReport(Set<Tuple2<ReportGridColumnDefinition, Boolean>> columnDefinitions, List<Tuple2<Application, ArrayList<Object>>> reportRows) throws IOException {
List<String> headers = mkHeaderStrings(columnDefinitions);
StringWriter writer = new StringWriter();
CsvListWriter csvWriter = new CsvListWriter(writer, CsvPreference.EXCEL_PREFERENCE);
csvWriter.write(headers);
reportRows.forEach(unchecked(row -> csvWriter.write(simplify(row))));
csvWriter.flush();
return writer.toString().getBytes();
}
use of org.supercsv.io.CsvListWriter in project waltz by khartec.
the class SurveyInstanceExtractor method mkCSVReport.
private byte[] mkCSVReport(List<SurveyQuestion> questions, List<List<Object>> reportRows) throws IOException {
List<String> headers = mkHeaderStrings(questions);
StringWriter writer = new StringWriter();
CsvListWriter csvWriter = new CsvListWriter(writer, CsvPreference.EXCEL_PREFERENCE);
csvWriter.write(headers);
reportRows.forEach(unchecked(row -> csvWriter.write(simplify(row))));
csvWriter.flush();
return writer.toString().getBytes();
}
use of org.supercsv.io.CsvListWriter in project hive by apache.
the class SeparatedValuesOutputFormat method getFormattedStr.
private String getFormattedStr(String[] vals) {
StringWriter strWriter = new StringWriter();
CsvListWriter writer = new CsvListWriter(strWriter, getCsvPreference());
if (vals.length > 0) {
try {
writer.write(vals);
} catch (IOException e) {
beeLine.error(e);
} finally {
IOUtils.closeStream(writer);
}
}
return strWriter.toString();
}
use of org.supercsv.io.CsvListWriter in project waltz by khartec.
the class CustomDataExtractor method mkCSVReport.
private byte[] mkCSVReport(List<List<Object>> reportRows, List<String> headers) throws IOException {
StringWriter writer = new StringWriter();
CsvListWriter csvWriter = new CsvListWriter(writer, CsvPreference.EXCEL_PREFERENCE);
csvWriter.write(headers);
reportRows.forEach(unchecked(row -> csvWriter.write(simplify(row))));
csvWriter.flush();
return writer.toString().getBytes();
}
Aggregations