當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。