stanfordnlp/CoreNLP · error · RuntimeException
Error: Line has too few tab-separated columns (${maxColumns}
Error message
Error: Line has too few tab-separated columns (${maxColumns}) for ${flags.length} columns required by specified properties: ${line} What it means
After per-line checks pass, readDataset verifies each line has at least as many tab-separated columns as the number of feature properties (flags.length) configured. A line with fewer columns cannot supply values for all configured features, so it throws a RuntimeException reporting the observed max column count and the offending line. Note the count shown is maxColumns (the widest line seen), not the offending line's width.
Solutions
- Add the missing tab-separated columns to the offending line so it matches flags.length
- Reduce the column mappings in your properties file to match the data's actual column count
- Verify delimiters are real tabs (the splitter is tab-based)
Example fix
// before (3 columns, properties need 4) label f1 f2 // after label f1 f2 f3
Defensive patterns
Strategy: validation
Validate before calling
int minCols = lines.stream().mapToInt(l -> l.split("\t", -1).length).min().orElse(0); if (minCols < flagsCount) throw new IllegalStateException("File has only " + minCols + " columns, need " + flagsCount); Type guard
null
Try / catch
try { readDataset(path); } catch (RuntimeException e) { log.error("Column count mismatch between properties and data: " + e.getMessage(), e); } Prevention
- Keep the properties column mappings and the TSV schema in sync
- Count columns (head -1 file | awk -F'\t' '{print NF}') before running
- Reduce configured columns when switching to smaller test files
When it happens
Trigger: Running readDataset (via dataInfo or readTestExamples) when the properties file defines more feature columns (e.g. columns 0..N) than some data line provides tab-separated fields.
Common situations: Mismatch between the properties file's column definitions and the actual TSV; a short row in the middle of the file; switching to a test file with fewer columns without updating properties.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Line format error at line ${lineNo}: ${line}
- Dataset could not be loaded
- Not enough columns for format ${format}
- Unrecognized format specification in ${format}
- addFeature was called with a features object that is neither
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a123f4b7626173b0.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:467
if (line.matches("\\s#.*")) {
continue;
}
}
String[] strings = splitLineToFields(line);
if (strings.length < 2) {
throw new RuntimeException("Line format error at line " + lineNo + ": " + line);
}
if (strings.length < minColumns) {
minColumns = strings.length;
}
if (strings.length > maxColumns) {
maxColumns = strings.length;
}
if (inTestPhase) {
lineInfos.add(strings);
}
if (strings.length < flags.length) {
throw new RuntimeException("Error: Line has too few tab-separated columns (" + maxColumns +
") for " + flags.length + " columns required by specified properties: " + line);
}
dataset.add(makeDatumFromStrings(strings));
}
if (lineNo > 0 && minColumns != maxColumns) {
logger.info("WARNING: Number of tab-separated columns in " +
filename + " varies between " + minColumns + " and " + maxColumns);
}
} catch (Exception e) {
throw new RuntimeException("Dataset could not be loaded", e);
}
}
logger.info("Reading dataset from " + filename + " ... done [" + tim.toSecondsString() + "s, " + dataset.size() + " items].");
return new Pair<>(dataset, lineInfos);
}
/** Split according to whether we are using tsv file (default) or csv files. */
private String[] splitLineToFields(String line) {View on GitHub (pinned to 1b7edd19c4)