public void setFieldNames(final String header) { try { setFieldNames(parseLine(header)); } catch (Exception e) { throw new ParseException(e, "Unable to parse header [%s]", header); } }
@Override public Map<String, Object> parseToMap(final String input) { if (!supportSkipHeaderRows && (hasHeaderRow || maxSkipHeaderRows > 0)) { throw new UnsupportedOperationException("hasHeaderRow or maxSkipHeaderRows is not supported. " + "Please check the indexTask supports these options."); } try { List<String> values = parseLine(input); if (skippedHeaderRows < maxSkipHeaderRows) { skippedHeaderRows++; return null; } if (hasHeaderRow && !hasParsedHeader) { if (fieldNames == null) { setFieldNames(values); } hasParsedHeader = true; return null; } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }
public void setFieldNames(final String header) { try { setFieldNames(parseLine(header)); } catch (Exception e) { throw new ParseException(e, "Unable to parse header [%s]", header); } }
@Override public Map<String, Object> parseToMap(final String input) { if (!supportSkipHeaderRows && (hasHeaderRow || maxSkipHeaderRows > 0)) { throw new UnsupportedOperationException("hasHeaderRow or maxSkipHeaderRows is not supported. " + "Please check the indexTask supports these options."); } try { List<String> values = parseLine(input); if (skippedHeaderRows < maxSkipHeaderRows) { skippedHeaderRows++; return null; } if (hasHeaderRow && !hasParsedHeader) { if (fieldNames == null) { setFieldNames(values); } hasParsedHeader = true; return null; } if (fieldNames == null) { setFieldNames(ParserUtils.generateFieldNames(values.size())); } return Utils.zipMapPartial(fieldNames, Iterables.transform(values, valueFunction)); } catch (Exception e) { throw new ParseException(e, "Unable to parse row [%s]", input); } }