Package au.com.bytecode.opencsv_voltpatches

Examples of au.com.bytecode.opencsv_voltpatches.CSVWriter


import au.com.bytecode.opencsv_voltpatches.CSVWriter;

public class TestVoltTableUtil extends Mockito {
    @Test
    public void testCSVNullConversion() throws IOException {
        CSVWriter writer = mock(CSVWriter.class);
        ColumnInfo[] columns = new ColumnInfo[] {new ColumnInfo("", VoltType.BIGINT),
                                                 new ColumnInfo("", VoltType.FLOAT),
                                                 new ColumnInfo("", VoltType.DECIMAL),
                                                 new ColumnInfo("", VoltType.STRING),
                                                 new ColumnInfo("", VoltType.TIMESTAMP),
View Full Code Here


     * Round-trip the time, see if it's still the same.
     * @throws IOException
     */
    @Test
    public void testCSVTimestamp() throws IOException {
        CSVWriter writer = mock(CSVWriter.class);
        ColumnInfo[] columns = new ColumnInfo[] {new ColumnInfo("", VoltType.TIMESTAMP)};
        ArrayList<VoltType> columnTypes = new ArrayList<VoltType>();
        // To make sure we have microseconds we get millisecond from current timestamp
        // and add remainder to ensure we have micros in timestamp.
        TimestampType ts = new TimestampType((System.currentTimeMillis() * 1000) + System.currentTimeMillis() % 1000);
View Full Code Here

            Throwables.propagate(ex);
        }

        StringWriter sw = new StringWriter(16384);
        PrintWriter pw = new PrintWriter(sw,true);
        CSVWriter csw = new CSVWriter(pw);
        StringBuffer sb = sw.getBuffer();

        stringValues = new String[columnCount];

        try {
            while (rslt.next()) {
                long rownum = m_totalRowCount.incrementAndGet();

                Arrays.fill(stringValues, "NULL");
                columnValues = new Object[columnCount];

                lineData = new RowWithMetaData(new String[1], rownum);

                try {
                    for (int i = 0; i < columnCount; ++i) {
                        columnValues[i] = acceptors[i].convert();
                        stringValues[i] = acceptors[i].format(columnValues[i]);
                    }

                    csw.writeNext(stringValues);
                    ((String[])lineData.rawLine)[0] = sb.toString();
                    sb.setLength(0);

                    m_loader.insertRow(lineData, columnValues);
View Full Code Here

            ArrayList<VoltType> columns,
            char delimiter,
            char fullDelimiters[],
            int lastNumCharacters) throws IOException {
        StringWriter sw = new StringWriter((int)(lastNumCharacters * 1.2));
        CSVWriter writer;
        if (fullDelimiters != null) {
            writer = new CSVWriter(sw,
                    fullDelimiters[0], fullDelimiters[1], fullDelimiters[2], String.valueOf(fullDelimiters[3]));
        }
        else if (delimiter == ',')
            // CSV
            writer = new CSVWriter(sw, delimiter);
        else {
            // TSV
            writer = CSVWriter.getStrictTSVWriter(sw);
        }
        toCSVWriter(writer, vt, columns);
View Full Code Here

        final int columnCount = t.getColumnCount();
        List<VoltType> columnTypes = new ArrayList<VoltType>(columnCount);
        for (int i = 0; i < columnCount; i++) {
            columnTypes.add(t.getColumnType(i));
        }
        CSVWriter csvWriter = new CSVWriter(new OutputStreamWriter(stream));
        if (includeColumnNames) {
            String[] columnNames = new String[columnCount];
            for (int i = 0; i < columnCount; i++) {
                columnNames[i] = t.getColumnName(i);
            }
            csvWriter.writeNext(columnNames);
        }
        VoltTableUtil.toCSVWriter(csvWriter, t, columnTypes);
    }
View Full Code Here

TOP

Related Classes of au.com.bytecode.opencsv_voltpatches.CSVWriter

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.