Package com.knowgate.misc

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


    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

    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

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

   * 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

TOP

Related Classes of com.knowgate.misc.CSVParser

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.