本文整理汇总了Java中com.univocity.parsers.csv.CsvParserSettings.setIgnoreTrailingWhitespaces方法的典型用法代码示例。如果您正苦于以下问题:Java CsvParserSettings.setIgnoreTrailingWhitespaces方法的具体用法?Java CsvParserSettings.setIgnoreTrailingWhitespaces怎么用?Java CsvParserSettings.setIgnoreTrailingWhitespaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.univocity.parsers.csv.CsvParserSettings
的用法示例。
在下文中一共展示了CsvParserSettings.setIgnoreTrailingWhitespaces方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
* Returns a DataFrame parsed from the stream specified stream
* @param stream the stream to parse
* @return the DataFrame parsed from stream
* @throws IOException if there stream read error
*/
private DataFrame<R,String> parse(CsvSourceOptions<R> options, InputStream stream) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, options.getCharset().orElse(StandardCharsets.UTF_8)))) {
final CsvRequestHandler handler = new CsvRequestHandler(options);
final CsvParserSettings settings = new CsvParserSettings();
settings.getFormat().setDelimiter(options.getDelimiter());
settings.setHeaderExtractionEnabled(options.isHeader());
settings.setLineSeparatorDetectionEnabled(true);
settings.setRowProcessor(handler);
settings.setIgnoreTrailingWhitespaces(true);
settings.setIgnoreLeadingWhitespaces(true);
settings.setMaxColumns(10000);
settings.setReadInputOnSeparateThread(false);
final CsvParser parser = new CsvParser(settings);
parser.parse(reader);
return handler.getFrame();
}
}
示例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);
}
}