I'm converting Resultset to CSV using Univocity parser. I want only the user provided fields to be present in the output CSV if the fields are present in the resultset. If the field is not present in the resultset the corresponding column should be blank. I have a restriction of not modifying the SQL query.
I'm using excludeFields() method but it is making the field values blank in the output CSV along with the delimiter.
example:
Name, Age, Email
Joe, 20, joe@example.com
After applying excludeFields("Age"). Since setHeaders() method has some known issues, I'm using my own logic to set headers.
Name, Email
Joe, , joe@example.com
But I want it to be like:
Name, Email
Joe, joe@example.com
Is there any way I can achieve it?