Examples of CSVFormat


Examples of com.foundationdb.server.service.externaldata.CsvFormat

    public static CsvFormat csvFormat(CopyStatementNode copyStmt,
                                      PostgresServerSession server) {
        String encoding = copyStmt.getEncoding();
        if (encoding == null)
            encoding = server.getMessenger().getEncoding();
        CsvFormat format = new CsvFormat(encoding);
        if (copyStmt.getDelimiter() != null)
            format.setDelimiter(copyStmt.getDelimiter());
        if (copyStmt.getQuote() != null)
            format.setQuote(copyStmt.getQuote());
        if (copyStmt.getEscape() != null)
            format.setEscape(copyStmt.getEscape());
        if (copyStmt.getNullString() != null)
            format.setNullString(copyStmt.getNullString());
        return format;
    }
View Full Code Here

Examples of org.apache.commons.csv.CSVFormat

    private BufferedReader getBufferedReader() throws IOException {
        return new BufferedReader(new FileReader(BIG_FILE));
    }

    private long parse(final Reader in, final boolean traverseColumns) throws IOException {
        final CSVFormat format = CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(false);
        long recordCount = 0;
        for (final CSVRecord record : format.parse(in)) {
            recordCount++;
            if (traverseColumns) {
                for (@SuppressWarnings("unused") final String value : record) {
                    // do nothing for now
                }
View Full Code Here

Examples of org.apache.commons.csv.CSVFormat

     * ignore empty lines allows the last data line to have a recordSeparator
     *
     * @return CSVFormat based on constructor settings.
     */
    private CSVFormat buildFormat() {
        CSVFormat format = CSVFormat.DEFAULT
                .withIgnoreEmptyLines(true)
                .withDelimiter(asControlCharacter(fieldDelimiter))
                .withQuoteChar(asControlCharacter(quoteCharacter));

        if (escapeCharacter != null) {
            format = format.withEscape(asControlCharacter(escapeCharacter));
        }

        switch(headerSource) {
        case FROM_TABLE:
            // obtain headers from table, so format should not expect a header.
            break;
        case IN_LINE:
            // an empty string array triggers csv loader to grab the first line as the header
            format = format.withHeader(new String[0]);
            break;
        case SUPPLIED_BY_USER:
            // a populated string array supplied by the user
            format = format.withHeader(columns.toArray(new String[columns.size()]));
            break;
        default:
            throw new RuntimeException("Header source was unable to be inferred.");

        }
View Full Code Here

Examples of org.apache.commons.csv.CSVFormat

     * ignore empty lines allows the last data line to have a recordSeparator
     *
     * @return CSVFormat based on constructor settings.
     */
    private CSVFormat buildFormat() {
        CSVFormat format = CSVFormat.DEFAULT
                .withIgnoreEmptyLines(true);
        if (userSuppliedMetaCharacters) {
            // list error checking handled in constructor above.
            // use 0 to keep default setting
            String delimiter = customMetaCharacters.get(0);
            String quote = customMetaCharacters.get(1);
            String escape = customMetaCharacters.get(2);

            if (!"0".equals(delimiter)) {
                format = format.withDelimiter(getCustomMetaCharacter(delimiter));
            }
            if (!"0".equals(quote)) {
                format = format.withQuoteChar(getCustomMetaCharacter(quote));
            }
            if (!"0".equals(quote)) {
                format = format.withEscape(getCustomMetaCharacter(escape));
            }

        }
        switch(headerSource) {
        case FROM_TABLE:
            // obtain headers from table, so format should not expect a header.
            break;
        case IN_LINE:
            // an empty string array triggers csv loader to grab the first line as the header
            format = format.withHeader(new String[0]);
            break;
        case SUPPLIED_BY_USER:
            // a populated string array supplied by the user
            format = format.withHeader(columns.toArray(new String[columns.size()]));
            break;
        default:
            throw new RuntimeException("Header source was unable to be inferred.");

        }
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

    // get filenames, headers & format
    String sourceID = prop.getPropertyString(
        ScriptProperties.HEADER_DATASOURCE_RAW_FILE);

    File sourceFile = this.analyst.getScript().resolveFilename(sourceID);
    CSVFormat inputFormat = this.analyst.getScript().determineInputFormat(sourceID)
    boolean headers = this.analyst.getScript().expectInputHeaders(sourceID);
     
    // read the file
    this.rowCount = 0;
    this.missingCount = 0;
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

   * @param af The analyst format.
   * @return The CSV format.
   */
  public static CSVFormat convertToCSVFormat(final AnalystFileFormat af) {
    if (af == AnalystFileFormat.DECPNT_COMMA) {
      return new CSVFormat('.', ',');
    } else if (af == AnalystFileFormat.DECPNT_SPACE) {
      return new CSVFormat('.', ' ');
    } else if (af == AnalystFileFormat.DECPNT_SEMI) {
      return new CSVFormat('.', ';');
    } else if (af == AnalystFileFormat.DECCOMMA_SPACE) {
      return new CSVFormat(',', ' ');
    } else if (af == AnalystFileFormat.DECCOMMA_SEMI) {
      return new CSVFormat(',', ';');
    } else {
      return null;
    }
  }
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

    final File sourceFile = getScript().resolveFilename(sourceID);
    final File targetFile = getScript().resolveFilename(targetID);

    // get formats
    final CSVFormat inputFormat = getScript()
        .determineInputFormat(sourceID);
    final CSVFormat outputFormat = getScript().determineOutputFormat();

    // mark generated
    getScript().markGenerated(targetID);

    // prepare to normalize
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

    EncogLogging.log(EncogLogging.LEVEL_DEBUG, "Beginning segregate");
    EncogLogging.log(EncogLogging.LEVEL_DEBUG, "source file:" + sourceID);

    // get formats
    final CSVFormat inputFormat = getScript()
        .determineInputFormat(sourceID);
    final CSVFormat outputFormat = getScript().determineOutputFormat();

    // prepare to segregate
    final boolean headers = getScript().expectInputHeaders(sourceID);
    final SegregateCSV seg = new SegregateCSV();
    seg.setScript(getScript());
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

    // get filenames
    final String sourceID = getProp().getPropertyString(
        ScriptProperties.GENERATE_CONFIG_SOURCE_FILE);
    final String targetID = getProp().getPropertyString(
        ScriptProperties.GENERATE_CONFIG_TARGET_FILE);
    final CSVFormat format = getAnalyst().getScript().determineInputFormat(
        sourceID);

    EncogLogging.log(EncogLogging.LEVEL_DEBUG, "Beginning generate");
    EncogLogging.log(EncogLogging.LEVEL_DEBUG, "source file:" + sourceID);
    EncogLogging.log(EncogLogging.LEVEL_DEBUG, "target file:" + targetID);
View Full Code Here

Examples of org.encog.util.csv.CSVFormat

    String sourceID = prop.getPropertyString(
        ScriptProperties.HEADER_DATASOURCE_RAW_FILE);

    File sourceFile = this.analyst.getScript().resolveFilename(sourceID);

    CSVFormat inputFormat = this.analyst.getScript().determineInputFormat(sourceID);
   
    boolean headers = this.analyst.getScript().expectInputHeaders(sourceID);
 
    int rowSize = this.axisMapping.size();
   
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.