本文整理汇总了Java中com.univocity.parsers.csv.CsvParserSettings.setEmptyValue方法的典型用法代码示例。如果您正苦于以下问题:Java CsvParserSettings.setEmptyValue方法的具体用法?Java CsvParserSettings.setEmptyValue怎么用?Java CsvParserSettings.setEmptyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.univocity.parsers.csv.CsvParserSettings
的用法示例。
在下文中一共展示了CsvParserSettings.setEmptyValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSettings
import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
* Creates the CsvParserSettings.
*
* @param delimiter the delimiter
* @param quote the quote
* @param escape the escape
* @param linebreak the linebreak
* @return the csv parser settings
*/
private CsvParserSettings createSettings(final char delimiter, final char quote, final char escape, final char[] linebreak) {
CsvFormat format = new CsvFormat();
format.setDelimiter(delimiter);
format.setQuote(quote);
format.setQuoteEscape(escape);
format.setLineSeparator(linebreak);
format.setNormalizedNewline(CSVSyntax.getNormalizedLinebreak(linebreak));
format.setComment('\0');
CsvParserSettings settings = new CsvParserSettings();
settings.setEmptyValue("");
settings.setNullValue("");
settings.setFormat(format);
return settings;
}
示例2: 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;
}
示例3: configureParserSettings
import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void configureParserSettings(CsvParserSettings settings) {
super.configureParserSettings(settings);
if (emptyValue != null) {
settings.setEmptyValue(emptyValue);
}
}
示例4: readRecordsFromTestFile
import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
* Return a List<String[]> of the parsed file.
* The first item in the list <code>list.get(0)</code> is a <code>String[]<code/> of headers. The rest
* of the elements are rows in the file
*
* @param pathToFile Full path in File System to a CSV file that contains records
* @return List<String[]> where the first record is the field names and the rest are the records
*/
public static List<String[]> readRecordsFromTestFile(String pathToFile) {
// The settings object provides many configuration options
CsvParserSettings parserSettings = new CsvParserSettings();
//You can configure the parser to automatically detect what line separator sequence is in the input
parserSettings.setLineSeparatorDetectionEnabled(true);
// A RowListProcessor stores each parsed row in a List.
RowListProcessor rowProcessor = new RowListProcessor();
// You can configure the parser to use a RowProcessor to process the values of each parsed row.
// You will find more RowProcessors in the 'com.univocity.parsers.common.processor' package, but you can also create your own.
parserSettings.setRowProcessor(rowProcessor);
parserSettings.setEmptyValue(StringUtils.EMPTY);
parserSettings.setNullValue(StringUtils.EMPTY);
// Let's consider the first parsed row as the headers of each column in the file.
parserSettings.setHeaderExtractionEnabled(true);
DatasetParser datasetParser = new DatasetParser();
datasetParser.getParserForFile(pathToFile, parserSettings);
// get the parsed records from the RowListProcessor here.
// Note that different implementations of RowProcessor will provide different sets of functionalities.
String[] headers = rowProcessor.getHeaders();
List<String[]> rows = rowProcessor.getRows();
List<String[]> results = new ArrayList<>();
results.add(headers);
results.addAll(rows);
return results;
}