All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geneweaver.io.reader.MapCSVReader Maven / Gradle / Ivy

There is a newer version: 2.7.12
Show newest version
package org.geneweaver.io.reader;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.csv.CSVRecord;

public class MapCSVReader extends AbstractCSVReader> {
	@Override
	protected Map create(CSVRecord row) throws ReaderException {
		return row.toMap();
	}
	
	// Can be used to fix lines read in with funny invisible 
	// whitespace characters in UTF-16 space.
	public static Map toAscii(Map line) {
		Map ret = new LinkedHashMap<>();
		for (Map.Entry entry : line.entrySet()) {
			String key = entry.getKey();
			String val = entry.getValue();
			key = key.replaceAll("[^\\x00-\\x7F]", "");
			ret.put(key, val);
		}
		return ret;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy