Examples of CSVParser

There is one exception to the commonly-accepted parsing rules: Embedded line breaks in a quoted field are not parsed but instead interpreted as the premature end of a record. This was a deliberate decision given the scope of this parser and the fact that it parses only a single line of input. @author Johannes Rössel
  • weave.utils.CSVParser
    Parses and generates CSV-encoded tables. Also supports custom delimiters and quotes. @author adufilie

  • Examples of com.fasterxml.jackson.dataformat.csv.CsvParser

                enc = _bigEndian ? JsonEncoding.UTF32_BE : JsonEncoding.UTF32_LE;
            } else {
                throw new RuntimeException("Internal error"); // should never get here
            }
            _context.setEncoding(enc);
            return new CsvParser(_context, _recycler,  baseFeatures, csvFeatures, _codec,
                    _createReader(enc));
        }
    View Full Code Here

    Examples of com.knowgate.misc.CSVParser

        String[] aCols = Gadgets.split (removeQuotes(sColList), ',');

        iColCount = aCols.length;

        CSVParser oParser = new CSVParser (sCharSet);

        oParser.parseFile (sFilePath, sColList.replace(',',sColDelim.charAt(0)));

        final int iRowCount = oParser.getLineCount();

        oResults = new Vector (iRowCount, 1);

        for (int r=0; r<iRowCount; r++) {
          oRow = new Vector (iColCount);

          for (int c=0; c<iColCount; c++)
            oRow.add (oParser.getField(c,r));

          oResults.add (oRow);
        } // next

        if (DebugFile.trace) {
    View Full Code Here

    Examples of com.knowgate.misc.CSVParser

        Vector oRow;

        String[] aCols = Gadgets.split (removeQuotes(sColList), ',');

        CSVParser oParser = new CSVParser (sCharSet);

        oParser.parseData (aData, sColList.replace(',',sColDelim.charAt(0)));

        final int iRowCount = oParser.getLineCount();
        iColCount = aCols.length;

        oResults = new Vector (iRowCount, 1);

        for (int r=0; r<iRowCount; r++) {
          oRow = new Vector (iColCount);

          for (int c=0; c<iColCount; c++)
            oRow.add (oParser.getField(c,r));

          oResults.add (oRow);
        } // next

        if (DebugFile.trace) {
    View Full Code Here

    Examples of com.knowgate.misc.CSVParser

        TableLoader oTblLdr = new TableLoader(sTableName);
        oTblLdr.prepare(getConnection(),oColList);
        String[] aColumns = oTblLdr.columnNames();

        CSVParser oCsvPrsr = new CSVParser(sEncoding);
        oCsvPrsr.parseFile(sFilePath, Gadgets.join(aColumns,"\t"));
        final int nLines = oCsvPrsr.getLineCount();
        final int nCols = oCsvPrsr.getColumnCount();

        getConnection().setAutoCommit(false);

        for (int l=0; l<nLines; l++) {
          c = -1;
          try {
            while (++c<nCols) {
              f = oCsvPrsr.getField(c,l);
              oTblLdr.put(c, f);
            } // wend  
            oTblLdr.store(getConnection(), "", iFlags);
            oTblLdr.setAllColumnsToNull();
          getConnection().commit();
          } catch (Exception xcpt) {
            iErrors++;
            String sTrc = "";
            try { sTrc = com.knowgate.debug.StackTraceUtil.getStackTrace(xcpt); } catch (IOException ignore) {}
            if (null!=oStrLog) oStrLog.append(xcpt.getClass().getName()+" for value "+f+" at line " + String.valueOf(l+1) + " column "+String.valueOf(c+1)+" of type "+oColList.getColumn(c).getSqlTypeName()+": " + xcpt.getMessage() + "\t" + oCsvPrsr.getLine(l) + "\n" + sTrc);
          getConnection().rollback();
            oTblLdr.setAllColumnsToNull();
            break;
          }
        } // next
    View Full Code Here

    Examples of com.knowgate.misc.CSVParser

      /**
       * Default constructor
       */
      public DirectList() {
        oCSV = new CSVParser();
      }
    View Full Code Here

    Examples of com.knowgate.misc.CSVParser

       * Constructor
       * @param String Name of character set to be used when parsing files (ISO-8859-1, UTF-8, etc.)
       * @since 3.0
       */
      public DirectList(String sCharSetName) {
        oCSV = new CSVParser(sCharSetName);
      }
    View Full Code Here

    Examples of com.manning.hip.ch3.csv.CSVParser

        this.adjClose = adjClose;
      }

      public static StockPriceWritable fromLine(String line)
          throws IOException {
        CSVParser parser = new CSVParser();
        String[] parts = parser.parseLine(line);

        StockPriceWritable stock = new StockPriceWritable(
            //<co id="ch03_comment_seqfile_write3"/>
            parts[0], parts[1], Double.valueOf(parts[2]),
            Double.valueOf(parts[3]),
    View Full Code Here

    Examples of org.apache.commons.csv.CSVParser

            for (int i=0; i<skipLines; i++) {
              r.readLine();
            }
          }

          CSVParser parser = new CSVParser(reader, strategy);

          // parse the fieldnames from the header of the file
          if (fieldnames==null) {
            fieldnames = parser.getLine();
            if (fieldnames==null) {
              throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Expected fieldnames in CSV input");
            }
            prepareFields();
          }

          // read the rest of the CSV file
          for(;;) {
            int line = parser.getLineNumber()// for error reporting in MT mode
            String[] vals = null;
            try {
              vals = parser.getLine();
            } catch (IOException e) {
              //Catch the exception and rethrow it with more line information
             input_err("can't read line: " + line, null, line, e);
            }
            if (vals==null) break;
    View Full Code Here

    Examples of org.apache.commons.csv.CSVParser

          this.base = base;
        }

        @Override
        void add(SolrInputDocument doc, int line, int column, String val) {
          CSVParser parser = new CSVParser(new StringReader(val), strategy);
          try {
            String[] vals = parser.getLine();
            if (vals!=null) {
              for (String v: vals) base.add(doc,line,column,v);
            } else {
              base.add(doc,line,column,val);
            }
    View Full Code Here

    Examples of org.apache.commons.csv.CSVParser

            Reader reader = null;
            boolean error = false;
            try {
                reader = IOHelper.buffered(new InputStreamReader(inputStream, IOHelper.getCharsetName(exchange)));
                CSVParser parser = new CSVParser(reader, strategy);

                if (skipFirstLine) {
                    // read one line ahead and skip it
                    parser.getLine();
                }

                CsvIterator csvIterator = new CsvIterator(parser, reader);
                return lazyLoad ? csvIterator : loadAllAsList(csvIterator);
            } catch (Exception e) {
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.