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


Java CSVParser.parseLine方法代码示例

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


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

示例1: initializeFromStream

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
/**
 * @param is The input stream to load
 */
public void initializeFromStream(InputStream is) throws IOException {
  CSVParser parser = new CSVParser();
  BufferedReader r = new BufferedReader(new InputStreamReader(is));
  String line = r.readLine();
  while (line != null) {
    String[] fields = parser.parseLine(line);
    if (fields.length != 3) {
      s_logger.warn("Line {} not in proper format.", line);
    } else {
      String scheme = fields[0];
      String id = fields[1];
      String normalization = fields[2];
      addSubscription(ExternalId.of(scheme, id), normalization);
      try {
        Thread.sleep(200L);
      } catch (InterruptedException ex) {
        // TODO Auto-generated catch block
        ex.printStackTrace();
      }
    }
    line = r.readLine();
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:PeriodicLiveDataTimeSeriesStorageServer.java

示例2: getList

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
/**
 * Helper to convert comma separated string into list
 * @param tokenizedList
 * @return
 */
private List<String> getList(final String tokenizedList){
	List<String> list = null;
	
	if(tokenizedList != null){
		list = new ArrayList<String>();
		CSVParser parser = new CSVParser();
		try {
			String[]  tokens = parser.parseLine(tokenizedList);
			for(String contributor: tokens){
				list.add(contributor.trim());
			}
		}catch (IOException e) {
			logger.error("Problem parsing list", e);
		}
	}
	
	return list;
}
 
开发者ID:robertzak,项目名称:goodreads-parser,代码行数:24,代码来源:GoodReadsParsingService.java

示例3: processResponseDocumentContent

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
@Transactional
private void processResponseDocumentContent(String content, Integer orderId, Integer projectId) throws Exception {
    BufferedReader reader = new BufferedReader(new StringReader(content));
    String line;
    String[] toks;
    CSVParser parser = new CSVParser();
    int counter = 1;
    reader.readLine();  //skip the first line which is a header.
    while ((line = reader.readLine()) != null) {
        counter++;
        line = line.trim();
        if (line.length() <= 0) continue;
        try {
            toks = parser.parseLine(line);

            if (toks.length != 4) {
                throw new RuntimeException("Invalid number of columns in row " + counter);
            }

            updateTranslation(orderId, new Long(toks[0]), toks[1], toks[2], toks[3]);
        } catch (Exception e) {
            logger.error("Invalid line: " + line + " (" + e.getMessage() + ")");
            throw new RuntimeException("Invalid line: " + line + " (" + e.getMessage() + ")");
        }
    }
}
 
开发者ID:qcri-social,项目名称:AIDR,代码行数:27,代码来源:TWBTranslationServiceImpl.java

示例4: exportReport

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
public void exportReport(EvalEvaluation evaluation, String groupIds, String evaluateeId, OutputStream outputStream, String exportType) {
	String[] groupIdsArray = new String [] {};
	CSVParser parser= new CSVParser();
	if (groupIds != null) {
		try {
			groupIdsArray = parser.parseLine(groupIds);
		} catch (IOException e) {
			//Is fine if this happens, empty array still
		}
	}
	exportReport(evaluation,groupIdsArray,evaluateeId,outputStream,exportType);
}
 
开发者ID:sakaicontrib,项目名称:evaluation,代码行数:13,代码来源:ReportExporterBean.java

示例5: getStrings

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public String[] getStrings(String name) {
    String[] rv = null;
    // get the count
    int count = getInt(name + ".count", -1);
    if (count == 0) {
        // zero count means empty array
        rv = new String[0];
    } else if (count > 0) {
        rv = new String[count];
        for (int i = 1; i <= count; i++)
        {
            rv[i - 1] = getString(name + "." + i, "");
        }
        // store the array in the properties
        this.addConfigItem(new ConfigItemImpl(name, rv, TYPE_ARRAY, SOURCE_GET_STRINGS), SOURCE_GET_STRINGS);
    } else {
        if (findConfigItem(name, null) != null) {
            // the config name exists
            String value = getString(name);
            if (StringUtils.isBlank(value)) {
                // empty value is an empty array
                rv = new String[0];
                this.addConfigItem(new ConfigItemImpl(name, rv, TYPE_ARRAY, SOURCE_GET_STRINGS), SOURCE_GET_STRINGS);
            } else {
                CSVParser csvParser = new CSVParser(',','"','\\',false,true); // should configure this for default CSV parsing
                try {
                    rv = csvParser.parseLine(value);
                    this.addConfigItem(new ConfigItemImpl(name, rv, TYPE_ARRAY, SOURCE_GET_STRINGS), SOURCE_GET_STRINGS);
                } catch (IOException e) {
                    log.warn("Config property ("+name+") read as multi-valued string, but failure occurred while parsing: "+e, e);
                }
            }
        }
    }
    return rv;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:40,代码来源:BasicConfigurationService.java

示例6: parseAdditionalContributors

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
/**
 * 
 * @param addContStr
 * @return
 */
private List<Contributor> parseAdditionalContributors(final String addContStr){
	List<Contributor> contributors = null;
	
	if(addContStr != null){
		contributors = new ArrayList<Contributor>();
		CSVParser parser = new CSVParser();
		try {
			String[]  tokens = parser.parseLine(addContStr);
			for(String contributor: tokens){
				/* TODO these are going to be artists, narrators, 
				 * additional authors and possibly editors. I don't
				 * think we can parse this, though we might be able to 
				 * guess based on the Binding and/or a user's shelves.
				 * 
				 * For now everyone gets to be "Unknown". Maybe add in
				 * data enrichment post parsing? 
				 */
				if((contributor != null) && (!"".equals(contributor))){
					contributors.add(getContributor(contributor,
							ContributorRole.UNKNOWN));
				}
			}
		}catch (IOException e) {
			logger.error("Problem parsing additional contributors", e);
		}
	}
	
	return contributors;
}
 
开发者ID:robertzak,项目名称:goodreads-parser,代码行数:35,代码来源:GoodReadsParsingService.java

示例7: toEntity

import au.com.bytecode.opencsv.CSVParser; //导入方法依赖的package包/类
protected Entity toEntity(String line) throws IOException
{
	Entity result = new DynamicEntity(entityType);
	CSVParser csvParser = getCsvParser();
	String[] columns = csvParser.parseLine(line);
	int i = 0;
	for (Attribute amd : entityType.getAtomicAttributes())
	{
		if (i < columns.length)
		{
			result.set(amd.getName(), DataConverter.convert(columns[i++], amd));
		}
	}
	return result;
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:16,代码来源:TabixRepository.java


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