当前位置: 首页>>代码示例>>Java>>正文


Java CsvParserSettings.setSkipEmptyLines方法代码示例

本文整理汇总了Java中com.univocity.parsers.csv.CsvParserSettings.setSkipEmptyLines方法的典型用法代码示例。如果您正苦于以下问题:Java CsvParserSettings.setSkipEmptyLines方法的具体用法?Java CsvParserSettings.setSkipEmptyLines怎么用?Java CsvParserSettings.setSkipEmptyLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.univocity.parsers.csv.CsvParserSettings的用法示例。


在下文中一共展示了CsvParserSettings.setSkipEmptyLines方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadZones

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
private void loadZones(ZipInputStream zipis) throws UnsupportedEncodingException{
	CsvParserSettings settings = new CsvParserSettings();
	settings.setSkipEmptyLines(true);
	settings.setNumberOfRowsToSkip(1);
	settings.trimValues(true);
	CsvFormat format = new CsvFormat();
	format.setDelimiter(',');
	format.setLineSeparator("\n");
	format.setCharToEscapeQuoteEscaping('\0');
	format.setQuote('"');
	settings.setFormat(format);
	CsvParser parser = new CsvParser(settings);
	
	Map<String, TimeZone> idMapRead = new HashMap<>();
	List<String[]> lines = parser.parseAll(new InputStreamReader(zipis, "UTF-8"));
	
	for(String[] entry : lines){
		TimeZone timeZone = new TimeZone();
		timeZone.setId(Integer.parseInt(entry[0]));
		timeZone.setCountryIso(entry[1]);
		timeZone.setName(entry[2]);
		idMapRead.put(timeZone.getName().trim().toUpperCase(), timeZone);
	}
	this.idMap = idMapRead;
	logger.info("loaded "+idMapRead.size()+" time zones");
}
 
开发者ID:mmarmol,项目名称:geolite2,代码行数:27,代码来源:TimeZoneFinder.java

示例2: initialize

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
 * Below method will be used to initialize the the parser
 *
 * @throws IOException
 */
public void initialize() throws IOException {
  CsvParserSettings parserSettings = new CsvParserSettings();
  parserSettings.getFormat().setDelimiter(csvParserVo.getDelimiter().charAt(0));
  parserSettings.getFormat().setComment(csvParserVo.getCommentCharacter().charAt(0));
  parserSettings.setLineSeparatorDetectionEnabled(true);
  parserSettings.setMaxColumns(
      getMaxColumnsForParsing(csvParserVo.getNumberOfColumns(), csvParserVo.getMaxColumns()));
  parserSettings.setNullValue("");
  parserSettings.setIgnoreLeadingWhitespaces(false);
  parserSettings.setIgnoreTrailingWhitespaces(false);
  parserSettings.setSkipEmptyLines(false);
  parserSettings.getFormat().setQuote(null == csvParserVo.getQuoteCharacter() ?
      '\"':csvParserVo.getQuoteCharacter().charAt(0));
  parserSettings.getFormat().setQuoteEscape(null == csvParserVo.getEscapeCharacter() ?
      '\\' :
      csvParserVo.getEscapeCharacter().charAt(0));
  blockCounter++;
  initializeReader();
  if (csvParserVo.getBlockDetailsList().get(blockCounter).getBlockOffset() == 0) {
    parserSettings.setHeaderExtractionEnabled(csvParserVo.isHeaderPresent());
  }
  parser = new CsvParser(parserSettings);
  parser.beginParsing(inputStreamReader);
}
 
开发者ID:carbondata,项目名称:carbondata,代码行数:30,代码来源:UnivocityCsvParser.java

示例3: mapCsv

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
@Benchmark
public void mapCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();

    //turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(false);

    settings.setRowProcessor(new BeanProcessor<City>(City.class) {
        @Override
        public void beanProcessed(City bean, ParsingContext context) {
            blackhole.consume(bean);
        }
    });

    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try(Reader reader = csvParam.getReader()) {
        parser.parse(reader);
    }
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:24,代码来源:UnivocityCsvParserBenchmark.java

示例4: parseCsv

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
@Benchmark
public void parseCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();

    //turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(false);

    settings.setRowProcessor(new AbstractRowProcessor() {
        @Override
        public void rowProcessed(String[] row, ParsingContext context) {
            blackhole.consume(row);
        }
    });

    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try(Reader reader = csvParam.getReader()) {
        parser.parse(reader);
    }
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:24,代码来源:UnivocityCsvParserBenchmark.java

示例5: main

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    CsvParam csvParam = new CsvParam();
    csvParam.setUp();

    CsvParserSettings settings = new CsvParserSettings();

    //turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(false);

    settings.setProcessor(new BeanProcessor<City>(City.class) {
        @Override
        public void beanProcessed(City bean, ParsingContext context) {
            System.out.println(bean);
        }
    });

    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try(Reader reader = csvParam.getReader()) {
        parser.parse(reader);
    }
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:26,代码来源:UnivocityCsvParserBenchmark.java

示例6: parseCsv

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
@Benchmark
public void parseCsv(Blackhole blackhole) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();

    //turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(true);

    settings.setRowProcessor(new AbstractRowProcessor() {
        @Override
        public void rowProcessed(String[] row, ParsingContext context) {
            blackhole.consume(row);
        }
    });

    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try(Reader reader = CsvParam.getSingleThreadedReader(quotes, nbRows)) {
        parser.parse(reader);
    }
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:24,代码来源:UnivocityConcurrentCsvParserBenchmark.java

示例7: mapCsv

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
@Benchmark
public void mapCsv(Blackhole blackhole) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();

    //turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);

    settings.setRowProcessor(new BeanProcessor<City>(City.class) {
        @Override
        public void beanProcessed(City bean, ParsingContext context) {
            blackhole.consume(bean);
        }
    });

    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try(Reader reader = CsvParam.getSingleThreadedReader(quotes, nbRows)) {
        parser.parse(reader);
    }
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:23,代码来源:UnivocityConcurrentCsvParserBenchmark.java

示例8: loadOffsets

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
private void loadOffsets(ZipInputStream zipis) throws UnsupportedEncodingException{
	CsvParserSettings settings = new CsvParserSettings();
	settings.setSkipEmptyLines(true);
	settings.setNumberOfRowsToSkip(1);
	settings.trimValues(true);
	CsvFormat format = new CsvFormat();
	format.setDelimiter(',');
	format.setLineSeparator("\n");
	format.setCharToEscapeQuoteEscaping('\0');
	format.setQuote('"');
	settings.setFormat(format);
	CsvParser parser = new CsvParser(settings);
	
	Map<Integer, TreeSet<Offset>> offsetMapRead = new HashMap<>();
	List<String[]> lines = parser.parseAll(new InputStreamReader(zipis, "UTF-8"));
	
	for(String[] entry : lines){
		Offset offset = new Offset(Long.parseLong(entry[2]));
		offset.setTimezoneId(Integer.parseInt(entry[0]));
		offset.setGmtOffset(Integer.parseInt(entry[3]));
		offset.setDst(BooleanUtils.toBooleanObject(Integer.parseInt(entry[4])));
		if(!offsetMapRead.containsKey(offset.getTimezoneId())){
			offsetMapRead.put(offset.getTimezoneId(), new TreeSet<>());
		}
		offsetMapRead.get(offset.getTimezoneId()).add(offset);
	}
	this.offsetMap = offsetMapRead;
	logger.info("loaded "+offsetMapRead.size()+" time zones offsets");
}
 
开发者ID:mmarmol,项目名称:geolite2,代码行数:30,代码来源:TimeZoneFinder.java

示例9: prepareParserSettings

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
static CsvParserSettings prepareParserSettings(RowProcessor rowProcessor) {
	final CsvParserSettings settings = new CsvParserSettings();
	settings.setInputBufferSize(16 * 1024);
	settings.setReadInputOnSeparateThread(false);
	settings.setCommentCollectionEnabled(false);
	settings.setEmptyValue("");
	settings.setNullValue(null);
	settings.setNumberOfRowsToSkip(1);
	settings.setSkipEmptyLines(false);
	settings.setProcessor(rowProcessor);
	return settings;
}
 
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:13,代码来源:RowIterator.java


注:本文中的com.univocity.parsers.csv.CsvParserSettings.setSkipEmptyLines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。