Search code examples
javaexport-to-csvsupercsv

Excluding null fields in super csv CsvBeanWriter


I have a class in which some of the fields may be null. I want to ignore such fields in my csv .Looking for functionality similar to @JsonInclude(value = Include.NON_NULL) in jackson. Null fields column header should also not come in CSV


Solution

  • It's up to you to (programatically) define the header, and which columns are written - Super CSV doesn't just automatically marshal an object to CSV for you (like Jackson does for JSON).

    You should check out the documentation on the website - in particular the section on partial writing.