use of com.Ostermiller.util.CSVParse in project eol-globi-data by jhpoelen.
the class CSVTSVUtilTest method readQuotesAgain.
@Test
public void readQuotesAgain() throws IOException {
CSVParse csvParser = CSVTSVUtil.createCSVParse(IOUtils.toInputStream("\"hello \"\"world\"\"\""));
assertThat(csvParser.nextValue(), is("hello \"world\""));
}
use of com.Ostermiller.util.CSVParse in project eol-globi-data by jhpoelen.
the class TermLookupServiceImpl method buildMapping.
private void buildMapping(List<URI> uriList) throws TermLookupServiceException {
mapping = new HashMap<>();
for (URI uri : uriList) {
try {
String response = contentToString(uri);
CSVParse parser = CSVTSVUtil.createCSVParse(new StringReader(response));
parser.changeDelimiter(getDelimiter());
if (hasHeader()) {
parser = CSVTSVUtil.createLabeledCSVParser(parser);
}
String[] line;
while ((line = parser.getLine()) != null) {
if (line.length < 4) {
LOG.info("line: [" + parser.getLastLineNumber() + "] in [" + uriList + "] contains less than 4 columns");
} else {
String sourceName = line[1];
String targetId = line[2];
String targetName = line[3];
if (StringUtils.isNotBlank(sourceName) && StringUtils.isNotBlank(targetId) && StringUtils.isNotBlank(targetName)) {
List<Term> terms = mapping.computeIfAbsent(sourceName, k -> new ArrayList<>());
terms.add(new TermImpl(targetId, targetName));
}
}
}
} catch (IOException e) {
throw new TermLookupServiceException("failed to retrieve mapping from [" + uriList + "]", e);
}
}
}
use of com.Ostermiller.util.CSVParse in project eol-globi-data by jhpoelen.
the class StudyImporterForMetaTable method importTable.
public static void importTable(InteractionListener interactionListener, TableParserFactory tableFactory, JsonNode tableConfig, Dataset dataset, ImportLogger importLogger) throws IOException, StudyImporterException {
if (tableConfig.has("tableSchema")) {
List<Column> columns = columnsForSchema(tableConfig, tableConfig.get("tableSchema"), dataset);
final CSVParse csvParse = tableFactory.createParser(tableConfig, dataset);
importAll(interactionListener, columns, csvParse, tableConfig, importLogger);
}
}
Aggregations