Search code examples
csvparsingunivocity

Throw exception if the expected header field is not in the received .csv file


Is it possible to throw exception when the expected header fields are not present in csv file, while parsing it via univocity parser


Solution

  • Are you processing the file into java beans? If that is the case, on your BeanProcessor instance, call setStrictHeaderValidationEnabled(true) and it will validate the input headers against the fields annotated with the @Parsed annotation.