languagetool-org/languagetool · error
Input file does not contain specified column
Error message
Input file does not contain specified column
What it means
RuleDetails.main reads an input CSV and validates that the user-specified column name exists in the original header before transforming records. It throws a RuntimeException when the requested column is absent from the CSV header.
Source
Thrown at languagetool-dev/src/main/java/org/languagetool/dev/RuleDetails.java:103
RuleDetails details = new RuleDetails(Languages.getLanguageForShortCode(langCode), ngramPath);
CSVFormat format = CSVFormat.RFC4180.withFirstRecordAsHeader();
try (CSVParser parser = CSVParser.parse(new File(inputFile), Charset.defaultCharset(), format)) {
try (CSVPrinter printer = new CSVPrinter(new BufferedWriter(new FileWriter(outputFile)), format)) {
Map<String, Integer> oldHeader = parser.getHeaderMap();
List<String> newHeader = new ArrayList<>(Collections.nCopies(oldHeader.size(), null));
for (Map.Entry<String, Integer> entry : oldHeader.entrySet()) {
newHeader.set(entry.getValue(), entry.getKey());
}
newHeader.add("description");
newHeader.add("category");
printer.printRecord(newHeader);
if (!oldHeader.containsKey(column)) {
throw new RuntimeException("Input file does not contain specified column " + column);
}
List<CSVRecord> records = parser.getRecords();
records.stream().sequential().map(record -> {
String ruleId = record.get(column);
Rule rule = details.getRuleById(ruleId);
List<String> transformedValues = new ArrayList<>();
record.iterator().forEachRemaining(transformedValues::add);
if (rule == null) {
transformedValues.add("");
transformedValues.add("");
} else {
transformedValues.add(rule.getDescription());
transformedValues.add(rule.getCategory().getId().toString());
}
return transformedValues;View on GitHub (pinned to 2e990059ce)
Solutions
- Check the actual header names in the input CSV and pass an exact match for the column
- Run the tool with the column name exactly as spelled in the file (case-sensitive)
- Inspect/clean the CSV header (remove BOM, trailing spaces) if the column looks correct
Example fix
// before mvn exec:java ... -Dexec.args="--column patternId rules.csv" // after head -1 rules.csv # confirm header, then use exact name mvn exec:java ... -Dexec.args="--column pattern_id rules.csv"
Defensive patterns
Strategy: validation
Validate before calling
try (CSVParser p = CSVFormat.DEFAULT.parse(reader)) {
Set<String> headers = p.getHeaderNames();
if (!headers.contains(column)) throw new IllegalArgumentException("Column not in CSV: " + column);
} Try / catch
try { new RuleDetails().main(args); } catch (RuntimeException e) { if (e.getMessage().startsWith("Input file does not contain specified column")) { System.err.println("Check header names with: head -1 <csv>"); } } Prevention
- Inspect the CSV header before choosing a column name
- Match column names exactly (case, spaces, no BOM)
- Pass column names programmatically from the parsed header rather than by hand
When it happens
Trigger: Running RuleDetails with a --column value that does not match any header in the input CSV, including case/whitespace mismatches or columns added only in newer file versions.
Common situations: Typo in the column name; using a column name from a different CSV format; BOM or trailing spaces in headers preventing exact match.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/e4e15c24ca429822.
Report an issue: GitHub.