com.opencsv.CSVReader.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中com.opencsv.CSVReader.<init>()方法的一些代码示例,展示了CSVReader.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CSVReader.<init>()方法的具体详情如下:
包路径:com.opencsv.CSVReader
类名称:CSVReader
方法名:<init>

CSVReader.<init>介绍

[英]Constructs CSVReader using defaults for all parameters.
[中]使用所有参数的默认值构造CSVReader。

代码示例

代码示例来源:origin: twosigma/beakerx

public CSVIterator(String fileName) throws IOException {
 this(new CSVReader(new FileReader(fileName)));
}

代码示例来源:origin: twosigma/beakerx

public Iterable<Map<String, Object>> readIterable(String fileName) throws IOException {
 CSVReader reader = new CSVReader(new FileReader(fileName));
 return () -> new CSVIterator(reader);
}

代码示例来源:origin: apache/incubator-gobblin

try (CSVReader csvr = new CSVReader(new StringReader(config.getString(path)));) {
 valueList = Lists.newArrayList(csvr.readNext());
} catch (IOException ioe) {

代码示例来源:origin: iSoron/uhabits

throws IOException
CSVReader reader = new CSVReader(new FileReader(file));
HashMap<String, Habit> map = new HashMap<>();

代码示例来源:origin: apache/incubator-gobblin

new CSVReader(new InputStreamReader(
            this.fileBasedExtractor.getFsHelper().getFileStream(file),
            ConfigurationKeys.DEFAULT_CHARSET_ENCODING), delimiter));
} else {
 reader = this.fileBasedExtractor.getCloser().register(
   new CSVReader(new InputStreamReader(
            this.fileBasedExtractor.getFsHelper().getFileStream(file),
            ConfigurationKeys.DEFAULT_CHARSET_ENCODING)));

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Procedure
@Description("apoc.load.csv('url',{config}) YIELD lineNo, list, map - load CSV fom URL as stream of values,\n config contains any of: {skip:1,limit:5,header:false,sep:'TAB',ignore:['tmp'],nullValues:['na'],arraySep:';',mapping:{years:{type:'int',arraySep:'-',array:false,name:'age',ignore:false}}")
public Stream<CSVResult> csv(@Name("url") String url, @Name(value = "config",defaultValue = "{}") Map<String, Object> config) {
  boolean failOnError = booleanValue(config, "failOnError", true);
  try {
    CountingReader reader = FileUtils.readerFor(url);
    char separator = separator(config, "sep", DEFAULT_SEP);
    char arraySep = separator(config, "arraySep", DEFAULT_ARRAY_SEP);
    long skip = longValue(config, "skip", 0L);
    boolean hasHeader = booleanValue(config, "header", true);
    long limit = longValue(config, "limit", Long.MAX_VALUE);
    EnumSet<Results> results = EnumSet.noneOf(Results.class);
    for (String result : value(config, "results", asList("map","list"))) {
      results.add(Results.valueOf(result));
    }
    List<String> ignore = value(config, "ignore", emptyList());
    List<String> nullValues = value(config, "nullValues", emptyList());
    Map<String, Map<String, Object>> mapping = value(config, "mapping", Collections.emptyMap());
    Map<String, Mapping> mappings = createMapping(mapping, arraySep, ignore);
    CSVReader csv = new CSVReader(reader, separator);
    String[] header = getHeader(hasHeader, csv, ignore, mappings);
    boolean checkIgnore = !ignore.isEmpty() || mappings.values().stream().anyMatch( m -> m.ignore);
    return StreamSupport.stream(new CSVSpliterator(csv, header, url, skip, limit, checkIgnore,mappings, nullValues,results), false);
  } catch (IOException e) {
    if(!failOnError)
      return Stream.of(new  CSVResult(new String[0], new String[0], 0, true, Collections.emptyMap(), emptyList(), EnumSet.noneOf(Results.class)));
    else
      throw new RuntimeException("Can't read CSV from URL " + cleanUrl(url), e);
  }
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

final CSVReader csv = new CSVReader(reader, clc.getDelimiter());
final String[] loadCsvCompatibleHeader = fields.stream().map(f -> f.getName()).toArray(String[]::new);

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

final CSVReader csv = new CSVReader(reader, clc.getDelimiter(), clc.getQuotationCharacter());

代码示例来源:origin: http-builder-ng/http-builder-ng

private CSVReader makeReader(final Reader reader) {
  if (hasQuoteChar()) {
    return new CSVReader(reader, separator, quoteChar);
  } else {
    return new CSVReader(reader, separator);
  }
}

代码示例来源:origin: io.github.http-builder-ng/http-builder-ng-core

private CSVReader makeReader(final Reader reader) {
  if (hasQuoteChar()) {
    return new CSVReader(reader, separator, quoteChar);
  } else {
    return new CSVReader(reader, separator);
  }
}

代码示例来源:origin: org.codehaus.groovy.modules/http-builder-ng-core

private CSVReader makeReader(final Reader reader) {
  if(hasQuoteChar()) {
    return new CSVReader(reader, separator, quoteChar);
  }
  else {
    return new CSVReader(reader, separator);
  }
}

代码示例来源:origin: com.opencsv/opencsv

/**
 * Creates the CSVReader.
 * @return The CSVReader based on the set criteria.
 */
public CSVReader build() {
  final ICSVParser parser = getOrCreateCsvParser();
  return new CSVReader(reader, skipLines, parser, keepCR, verifyReader, multilineLimit, errorLocale);
}

代码示例来源:origin: TGAC/miso-lims

public DelimitedSpreadsheetWrapper(InputStream in) throws IOException {
 try (CSVReader reader = new CSVReader(new InputStreamReader(in))) {
  this.rows = reader.readAll();
 }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

protected CSVReader getCSVReader() throws IOException {
  BufferedReader br = getLineReader();
  return new CSVReader(br, delimiter, quoteCharacter, escapeCharacter);
}

代码示例来源:origin: md-5/SpecialSource

private void readIntoMap(File file, Map<String, String> map) throws IOException {
  try (FileReader fileReader = new FileReader(file);
     CSVReader csvReader = new CSVReader(fileReader)) {
    String[] line;
    while ((line = csvReader.readNext()) != null) {
      if (line.length == 0) {
        continue;
      }
      Preconditions.checkArgument(line.length >= 2, "Invalid csv line: %s", (Object) line);
      map.put(line[0], line[1]);
    }
  }
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-jobs

/**
 * Read the CSV file and send interactions to the consumer
 *
 * @param consumer the consumer (first param is the InteractionRelation and the second the list of
 *     alternative words)
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void read(BiConsumer<InteractionDefinition, Collection<String>> consumer)
  throws IOException {
 try (CSVReader reader = new CSVReader(new FileReader(inputFilename))) {
  StreamSupport.stream(reader.spliterator(), false).forEach(r -> processRecord(r, consumer));
 }
}

代码示例来源:origin: dstl/baleen

/**
 * Read the CSV file and send interactions to the consumer
 *
 * @param consumer the consumer (first param is the InteractionRelation and the second the list of
 *     alternative words)
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void read(BiConsumer<InteractionDefinition, Collection<String>> consumer)
  throws IOException {
 try (CSVReader reader = new CSVReader(new FileReader(inputFilename))) {
  StreamSupport.stream(reader.spliterator(), false).forEach(r -> processRecord(r, consumer));
 }
}

代码示例来源:origin: io.mindmaps/migration-csv

/**
 * Migrate all the data in the given file based on the given template.
 * @param template parametrized graql insert query
 * @param file file containing data to be migrated
 * @return Graql insert statement representing the file
 */
public String graql(String template, File file){
  checkBatchSize();
  try (CSVReader reader =  new CSVReader(new FileReader(file), delimiter, '"', 0)){
    return resolve(template, reader).collect(joining(NEWLINE));
  } catch (IOException e){
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.metamodel/MetaModel-csv

protected CSVReader createCsvReader(int skipLines) {
  final Reader reader = FileHelper.getReader(_resource.read(), _configuration.getEncoding());
  return new CSVReader(reader, skipLines, createParser());
}

代码示例来源:origin: apache/metamodel

protected CSVReader createCsvReader(int skipLines) {
  final Reader reader = FileHelper.getReader(_resource.read(), _configuration.getEncoding());
  return new CSVReader(reader, skipLines, createParser());
}

相关文章