Search in sources :

Example 61 with CSVPrinter

use of org.apache.commons.csv.CSVPrinter in project drools-wb by kiegroup.

the class ScenarioCsvDownloadReportTest method generateAuditLogHeaderDMN.

@Test
public void generateAuditLogHeaderDMN() throws IOException {
    StringBuilder stringBuilder = new StringBuilder();
    CSVPrinter printer = getCSVPrinter(stringBuilder);
    scenarioCsvDownloadReport.generateAuditLogHeader(printer, DMN);
    String retrieved = stringBuilder.toString();
    commonCheckHeader(DMN_AUDIT_HEADER, retrieved);
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) Test(org.junit.Test)

Example 62 with CSVPrinter

use of org.apache.commons.csv.CSVPrinter in project drools-wb by kiegroup.

the class ScenarioCsvDownloadReportTest method generateOverallStatsHeaderRULE.

@Test
public void generateOverallStatsHeaderRULE() throws IOException {
    StringBuilder stringBuilder = new StringBuilder();
    CSVPrinter printer = getCSVPrinter(stringBuilder);
    scenarioCsvDownloadReport.generateOverallStatsHeader(printer, ScenarioSimulationModel.Type.RULE);
    String retrieved = stringBuilder.toString();
    commonCheckHeader(RULE_OVERALL_STATS_HEADER, retrieved);
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) Test(org.junit.Test)

Example 63 with CSVPrinter

use of org.apache.commons.csv.CSVPrinter in project drools-wb by kiegroup.

the class ScenarioCsvImportExportTest method setup.

@Before
public void setup() throws IOException {
    output = new StringBuilder();
    printer = new CSVPrinter(output, CSVFormat.EXCEL);
    scenarioCsvImportExport = new ScenarioCsvImportExport();
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) Before(org.junit.Before)

Example 64 with CSVPrinter

use of org.apache.commons.csv.CSVPrinter in project portfolio by buchen.

the class ScatterChartCSVExporter method writeToFile.

@Override
protected void writeToFile(File file) throws IOException {
    try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
        CSVPrinter printer = new CSVPrinter(writer);
        printer.setStrategy(STRATEGY);
        // write header
        printer.print(Messages.ColumnDataSeries);
        printer.print(chart.getAxisSet().getXAxis(0).getTitle().getText());
        printer.print(chart.getAxisSet().getYAxis(0).getTitle().getText());
        printer.println();
        // write body
        ISeries[] series = chart.getSeriesSet().getSeries();
        for (ISeries serie : series) {
            printer.print(serie.getId());
            printer.print(valueFormat.format(serie.getXSeries()[0]));
            printer.print(valueFormat.format(serie.getYSeries()[0]));
            printer.println();
        }
    }
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) ISeries(org.swtchart.ISeries) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 65 with CSVPrinter

use of org.apache.commons.csv.CSVPrinter in project portfolio by buchen.

the class TimelineChartCSVExporter method writeToFile.

@Override
protected void writeToFile(File file) throws IOException {
    try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
        CSVPrinter printer = new CSVPrinter(writer);
        printer.setStrategy(STRATEGY);
        ISeries[] series = chart.getSeriesSet().getSeries();
        // write header
        printer.print(Messages.ColumnDate);
        for (ISeries s : series) printer.print(s.getId());
        printer.println();
        // write body
        Date[] dateSeries = series[0].getXDateSeries();
        SeriesAdapter[] adapters = new SeriesAdapter[series.length];
        for (int ii = 0; ii < series.length; ii++) {
            if (discontinousSeries.contains(series[ii].getId()))
                adapters[ii] = new DiscontinousAdapter(series[ii]);
            else
                adapters[ii] = new DefaultAdapter(series[ii]);
        }
        for (int line = 0; line < dateSeries.length; line++) {
            printer.print(dateFormat.format(dateSeries[line]));
            for (int col = 0; col < adapters.length; col++) printer.print(adapters[col].format(dateSeries[line], line));
            printer.println();
        }
    }
}
Also used : ISeries(org.swtchart.ISeries) Date(java.util.Date) CSVPrinter(org.apache.commons.csv.CSVPrinter) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

CSVPrinter (org.apache.commons.csv.CSVPrinter)71 IOException (java.io.IOException)25 CSVFormat (org.apache.commons.csv.CSVFormat)20 OutputStreamWriter (java.io.OutputStreamWriter)17 StringWriter (java.io.StringWriter)14 Writer (java.io.Writer)13 ArrayList (java.util.ArrayList)12 FileOutputStream (java.io.FileOutputStream)11 Test (org.junit.Test)11 FileWriter (java.io.FileWriter)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 BufferedWriter (java.io.BufferedWriter)6 File (java.io.File)5 PrintWriter (java.io.PrintWriter)5 JSONArray (org.json.JSONArray)5 Map (java.util.Map)4 Word (ai.elimu.model.content.Word)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Letter (ai.elimu.model.content.Letter)2 LetterSoundCorrespondence (ai.elimu.model.content.LetterSoundCorrespondence)2