Java Code Examples for au.com.bytecode.opencsv.CSVParser#DEFAULT_QUOTE_CHARACTER

The following examples show how to use au.com.bytecode.opencsv.CSVParser#DEFAULT_QUOTE_CHARACTER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvStreamReader.java    From Quicksql with MIT License 5 votes vote down vote up
CsvStreamReader(Source source) {
  this(source,
    CSVParser.DEFAULT_SEPARATOR,
    CSVParser.DEFAULT_QUOTE_CHARACTER,
    CSVParser.DEFAULT_ESCAPE_CHARACTER,
    DEFAULT_SKIP_LINES,
    CSVParser.DEFAULT_STRICT_QUOTES,
    CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE);
}
 
Example 2
Source File: CsvLogRecordParser.java    From cognition with Apache License 2.0 5 votes vote down vote up
public void parse(Reader fileReader, String fileType, LogRecordCollector collector) throws IOException {
  try (CSVReader csvReader = new CSVReader(
      fileReader,
      config.getDelimiter(),
      CSVParser.DEFAULT_QUOTE_CHARACTER,
      CSVParser.NULL_CHARACTER);) {

    long line = 0;

    String[] headers = csvReader.readNext();
    line++;
    String[] fieldNames = constructFieldNames(headers, fileType, config.isCleanKeysForES());

    String[] record = null;
    while ((record = csvReader.readNext()) != null) {
      if (record.length != headers.length) {
        // unmatched record length
        LOGGER.warn("Unmatched record column count detected at line {} - header: {} record: {}",
            line, headers.length, record.length);
        continue;
      }
      LogRecord logRecord = new LogRecord();
      for (int i = 0; i < fieldNames.length; i++) {
        if (config.isSkipBlankFields() && StringUtils.isBlank(record[i])) {
          // skip
        } else {
          String value = config.isTrimFieldValue() ? StringUtils.trim(record[i]) : record[i];
          logRecord.setValue(fieldNames[i], value);
        }
      }
      collector.emit(logRecord);
    }
  }
}
 
Example 3
Source File: CsvStreamReader.java    From calcite with Apache License 2.0 5 votes vote down vote up
CsvStreamReader(Source source) {
  this(source,
      CSVParser.DEFAULT_SEPARATOR,
      CSVParser.DEFAULT_QUOTE_CHARACTER,
      CSVParser.DEFAULT_ESCAPE_CHARACTER,
      DEFAULT_SKIP_LINES,
      CSVParser.DEFAULT_STRICT_QUOTES,
      CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE);
}
 
Example 4
Source File: FileFixTableCreator.java    From celos with Apache License 2.0 5 votes vote down vote up
@Override
public FixTable create(TestRun testRun) throws Exception {
    try (CSVReader reader = new CSVReader(getFileReader(testRun), separator, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER)) {
        List<String[]> myEntries = reader.readAll();
        String[] colNames = myEntries.get(0);
        List<String[]> rowData = myEntries.subList(1, myEntries.size());
        return StringArrayFixTableCreator.createFixTable(colNames, rowData);
    }
}