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


Java CsvParserSettings.setLineSeparatorDetectionEnabled方法代码示例

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


在下文中一共展示了CsvParserSettings.setLineSeparatorDetectionEnabled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:24,代码来源:CsvSource.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: parseCSV

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
public void parseCSV(String fileName){
    CsvParserSettings parserSettings = new CsvParserSettings();
    parserSettings.setLineSeparatorDetectionEnabled(true);
    RowListProcessor rowProcessor = new RowListProcessor();
   parserSettings.setRowProcessor(rowProcessor);
    parserSettings.setHeaderExtractionEnabled(true);
    CsvParser parser = new CsvParser(parserSettings);
    parser.parse(new File(fileName));

    String[] headers = rowProcessor.getHeaders();
    List<String[]> rows = rowProcessor.getRows();
    for (int i = 0; i < rows.size(); i++){
    	System.out.println(Arrays.asList(rows.get(i)));
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:16,代码来源:TestUnivocity.java

示例4: getItererableCsv

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
private Iterable<Record> getItererableCsv(String source, String iteratorExpression) {
	CsvParserSettings settings = new CsvParserSettings();
	settings.setHeaderExtractionEnabled(true);
	settings.setLineSeparatorDetectionEnabled(true);
	settings.setDelimiterDetectionEnabled(true);
	settings.setReadInputOnSeparateThread(true);
	CsvParser parser = new CsvParser(settings);
	
	return parser.iterateRecords(new StringReader(source));
}
 
开发者ID:carml,项目名称:carml,代码行数:11,代码来源:CsvResolver.java

示例5: csvParser

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
static RowListProcessor csvParser(String path, boolean extractHeader) {
    CsvParserSettings parserSettings = new CsvParserSettings();
    parserSettings.setLineSeparatorDetectionEnabled(true);
    RowListProcessor rowProcessor = new RowListProcessor();
    parserSettings.setRowProcessor(rowProcessor);
    parserSettings.setHeaderExtractionEnabled(extractHeader);
    new CsvParser(parserSettings).parse(new File(path));
    return rowProcessor;
}
 
开发者ID:gboleslavsky,项目名称:HiveUnit,代码行数:10,代码来源:H.java

示例6: getParser

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
private CsvParser getParser() {
    CsvParserSettings parserSettings = new CsvParserSettings();
    parserSettings.setLineSeparatorDetectionEnabled(true);
    parserSettings.setHeaderExtractionEnabled(true);
    parserSettings.selectFields("label", "elapsed", "success", "timeStamp");
    RowListProcessor rowProcessor = new RowListProcessor();
    parserSettings.setProcessor(new ConcurrentRowProcessor(rowProcessor));
    return new CsvParser(parserSettings);
}
 
开发者ID:deliverymind,项目名称:lightning,代码行数:10,代码来源:JMeterCSVFileReader.java

示例7: getParser

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
private CsvParser getParser() {
    CsvParserSettings parserSettings = new CsvParserSettings();
    parserSettings.setLineSeparatorDetectionEnabled(true);
    parserSettings.setHeaderExtractionEnabled(false);
    parserSettings.selectIndexes(TIMESTAMP, VALUE, HOST_AND_METRIC);
    RowListProcessor rowProcessor = new RowListProcessor();
    parserSettings.setProcessor(new ConcurrentRowProcessor(rowProcessor));
    return new CsvParser(parserSettings);
}
 
开发者ID:deliverymind,项目名称:lightning,代码行数:10,代码来源:PerfMonDataReader.java

示例8: 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;
}
 
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:41,代码来源:UtilitiesForBlocksAndRecords.java

示例9: getParserForFile

import com.univocity.parsers.csv.CsvParserSettings; //导入方法依赖的package包/类
/**
 * This method generate a parser that starts an iterator-style parsing cycle that
 * does not rely in a {@link com.univocity.parsers.common.processor.RowProcessor}.
 * <p/>
 * To initialize a {@code CsvParser} with a default {@link com.univocity.parsers.common.processor.RowProcessor}
 * use {@link il.ac.technion.ie.experiments.parsers.DatasetParser#getParserForFile(String, com.univocity.parsers.csv.CsvParserSettings)} set the
 * parser in the {@link CsvParserSettings}
 *
 * @param pathToFile Full path in File System to a CSV file that contains records
 * @return an instance of {@link com.univocity.parsers.csv.CsvParser}
 */
public CsvParser getParserForFile(String pathToFile) {
    // The settings object provides many configuration options
    CsvParserSettings parserSettings = new CsvParserSettings();
    parserSettings.setLineSeparatorDetectionEnabled(true);
    CsvParser parser = createParser(parserSettings);
    // the 'parse' method will parse the file and delegate each parsed row to the RowProcessor you defined
    parser.beginParsing(getReader(pathToFile));

    return parser;
}
 
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:22,代码来源:DatasetParser.java


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