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


Java CSVRecord.toMap方法代码示例

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


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

示例1: parseDelimitedAreaFile

import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private  Map<String,String> parseDelimitedAreaFile(Integer exercise, Integer exercise_order)  {

		Map<String,String> list;
		CSVParser parser;
		URL resource;
		CSVFormat csvFormat;
		Charset charset;
		list = new HashMap<String,String>();
		try {
			
			resource =ResourceHelper.getResource(isFromGameResourceInput(),this.gamePath,this.setPath,exercise.toString(), exercise_order.toString(),"areaDelimitada.csv");
			charset= FileEncodingDetectorHelper.guessEncodingAndGetCharset(resource);
								
			csvFormat = CSVFormatHelper.getDefaultCSVFormat();
			parser = CSVParser.parse(resource, charset, csvFormat);
			for (CSVRecord record : parser )
				list = record.toMap();
		}
		catch (IOException e) {
			log.error("Fail",e);
		}
		return list;
		
	}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:25,代码来源:HangManExerciseDelimitedAreaLoader.java

示例2: parse

import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
public List<Map<String,String>> parse() throws BuenOjoCSVParserException {
	List<Map<String,String>> list = new ArrayList<>();
	CSVParser parser = null;
	try {
		parser = CSVFormat.RFC4180.withHeader()
								.withDelimiter(',')
								.withAllowMissingColumnNames(true)
								.parse(new InputStreamReader(this.inputStreamSource.getInputStream()));
	} catch (IOException e) {
		throw new BuenOjoCSVParserException(e.getMessage());
	}
	
	for (CSVRecord record :parser) {
		Map<String,String> map = record.toMap();
		list.add(map);
	}
	
	return list;
	
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:21,代码来源:SatelliteImageMetadataParser.java

示例3: getTypes

import org.apache.commons.csv.CSVRecord; //导入方法依赖的package包/类
private static Map<String, Type> getTypes(List<String> columns, Iterable<CSVRecord> records, Set<String> nullStrings) {
	// linked hash map has predictable iteration order
	// in particular, it retrieves keys in the order they are put in
	// we want this to make sure columns aren't in a different order than the file
	// they were read from (can be confusing, and messes up tests)
	Map<String, Type> types = new LinkedHashMap<>();

	for (CSVRecord record : records) {
		Map<String, String> recordMap = record.toMap();
		for (String key : columns) {
			String val = recordMap.get(key);
			if (val == null ||
				(types.containsKey(key) && types.get(key) == null) ||
				nullStrings.contains(val)) {
				continue;
			}

			Type type;
			try {
				Integer.parseInt(val);
				type = Type.INT_TYPE;
			} catch (NumberFormatException e) {
				try {
					Double.parseDouble(val);
					type = Type.DOUBLE_TYPE;
				} catch (NumberFormatException ee) {
					type = null;
				}
			}

			if (!types.containsKey(key)) {
				types.put(key, type);
			} else {
				if (!types.get(key).equals(type)) {
					types.put(key, null);
				}
			}
		}
	}
	return types;
}
 
开发者ID:mitdbg,项目名称:imputedb,代码行数:42,代码来源:HeapFileEncoder.java


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