Package org.apache.commons.csv

Examples of org.apache.commons.csv.CSVPrinter


      // unicode escapes (it's harmless since 'u' would not otherwise
      // be escaped.
      strat.setUnicodeEscapeInterpretation(true);
    }

    printer = new CSVPrinter(writer, strategy);
   

    CSVStrategy mvStrategy = new CSVStrategy(strategy.getDelimiter(), CSVStrategy.ENCAPSULATOR_DISABLED, CSVStrategy.COMMENTS_DISABLED, '\\', false, false, false, false);
    strat = mvStrategy;
View Full Code Here


      if (csvField.sf.multiValued() || csvField.values.size() > 1) {
        mvWriter.reset();
        csvField.mvPrinter.reset();
        // switch the printer to use the multi-valued one
        CSVPrinter tmp = printer;
        printer = csvField.mvPrinter;
        for (Fieldable fval : csvField.values) {
          csvField.sf.getType().write(this, csvField.name, fval);
        }
        printer = tmp;  // restore the original printer
View Full Code Here

        }

        mvWriter.reset();
        csvField.mvPrinter.reset();
        // switch the printer to use the multi-valued one
        CSVPrinter tmp = printer;
        printer = csvField.mvPrinter;
        for (Object fval : values) {
          writeVal(csvField.name, fval);
        }
        printer = tmp;  // restore the original printer
View Full Code Here

      // unicode escapes (it's harmless since 'u' would not otherwise
      // be escaped.
      strat.setUnicodeEscapeInterpretation(true);
    }

    printer = new CSVPrinter(writer, strategy);
   

    CSVStrategy mvStrategy = new CSVStrategy(strategy.getDelimiter(), CSVStrategy.ENCAPSULATOR_DISABLED, CSVStrategy.COMMENTS_DISABLED, '\\', false, false, false, false);
    strat = mvStrategy;
View Full Code Here

      if (csvField.sf.multiValued() || csvField.values.size() > 1) {
        mvWriter.reset();
        csvField.mvPrinter.reset();
        // switch the printer to use the multi-valued one
        CSVPrinter tmp = printer;
        printer = csvField.mvPrinter;
        for (Fieldable fval : csvField.values) {
          csvField.sf.getType().write(this, csvField.name, fval);
        }
        printer = tmp;  // restore the original printer
View Full Code Here

        }

        mvWriter.reset();
        csvField.mvPrinter.reset();
        // switch the printer to use the multi-valued one
        CSVPrinter tmp = printer;
        printer = csvField.mvPrinter;
        for (Object fval : values) {
          writeVal(csvField.name, fval);
        }
        printer = tmp;  // restore the original printer
View Full Code Here

      if (root.getChildren().size() > 0) {

        LOGGER.log(Level.INFO, "write structure to cache file");
        final PrintWriter out = new PrintWriter(cacheFilePath.toFile());
        final CSVPrinter csvOut = new CSVPrinter(out, CSVFormat.EXCEL);
        writeStructureToCSVPrinter(csvOut, root);
        out.close();
      }
    } catch (final IOException e) {
      throw new CloudsyncException("Can't write cache file on '" + cacheFilePath.toString() + "'", e);
View Full Code Here

    {
        Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8")); //$NON-NLS-1$

        try
        {
            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();
            }
        }
        finally
        {
            writer.close();
View Full Code Here

        Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8")); //$NON-NLS-1$

        try
        {
            CSVPrinter printer = new CSVPrinter(writer);
            printer.setStrategy(strategy);

            printer.println(new String[] { Messages.CSVColumn_Date, //
                            Messages.CSVColumn_Value, //
                            Messages.CSVColumn_Transferals, //
                            Messages.CSVColumn_DeltaInPercent, //
                            Messages.CSVColumn_CumulatedPerformanceInPercent });

            for (int ii = 0; ii < totals.length; ii++)
            {
                printer.print(Values.Date.format(dates[ii]));
                printer.print(Values.Amount.format(totals[ii]));
                printer.print(Values.Amount.format(transferals[ii]));
                printer.print(Values.Percent.format(delta[ii]));
                printer.print(Values.Percent.format(accumulated[ii]));
                printer.println();
            }
        }
        finally
        {
            writer.close();
View Full Code Here

    {
        Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8")); //$NON-NLS-1$

        try
        {
            CSVPrinter printer = new CSVPrinter(writer);
            printer.setStrategy(STRATEGY);

            printer.println(new String[] { Messages.CSVColumn_Date, //
                            Messages.CSVColumn_Type, //
                            Messages.CSVColumn_Value, //
                            Messages.CSVColumn_ISIN, //
                            Messages.CSVColumn_WKN, //
                            Messages.CSVColumn_TickerSymbol, //
                            Messages.CSVColumn_Description });

            for (AccountTransaction t : account.getTransactions())
            {
                printer.print(dateFormat.format(t.getDate()));
                printer.print(t.getType().toString());
                printer.print(currencyFormat.format(t.getAmount() / Values.Amount.divider()));

                printSecurityInfo(printer, t);

                printer.println();
            }
        }
        finally
        {
            writer.close();
View Full Code Here

TOP

Related Classes of org.apache.commons.csv.CSVPrinter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.