4

When using OpenCSV in order to write csv i'm using the CSVBindByName annotation this way:

    @CsvBindByName(column = "Date")
    private Long date;
    @CsvBindByName(column = "Post content")
    private String text;

But in the generated file the headers are all in UPPERCASE: DATE, POST CONTENT

Is there any way to generate the exact name in the annotation?

Udi
  • 598
  • 8
  • 19

1 Answers1

3

Seems that the CsvBindByName annotation always converts the column name to UpperCase based on the OpenCSV source code @ https://sourceforge.net/p/opencsv/source/ci/master/tree/src/main/java/com/opencsv/bean/HeaderColumnNameMappingStrategy.java#l210

You can try to use custom converter as detailed out here:

OpenCsv writes wrong column names with BeanToCsv + HeaderColumnNameTranslateMappingStrategy

piy26
  • 1,574
  • 11
  • 21
  • Thanks. I had some issues with the proposed answers but your reference to the problem in the code help me to extend it and fix there what i needed. – Udi Feb 11 '19 at 12:49