本文整理汇总了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");
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
示例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;
}