Using CSVBeanWriter to write empty Columns
A fast, programmer-friendly, free CSV library for Java
Brought to you by:
jamesbassett,
kbg
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Changed Version
Hi Ed,
I'll look into this, but my initial feeling is that it doesn't really make sense to use null as a header column. If you don't want to write the column, then why not remove it altogether from the nameMapping array? I don't believe you could actually write the header with writeHeader() if you have a null column name anyway.
James
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Hi James,
in my case there is a defined column list, which must be supplied. So I have to add a column, which has no representation in my bean. Just like in the reader-case, where I can omit a column from the file and the bean doesn't have to have a dummy property.
I did the following:
- writeHeader with a String[] containing all header columns filled
- write with a String[], where the "omitted-to-be" columns were replaced with null
null within the writeHeader would lead to an NPE I guess.
regards
ed
I've updated CsvBeanWriter to allow for null entries in the nameMapping array ( see revision 231). This will result in an empty column (""). Also, note that I've updated all writers to write null as "" (previously you had to use a ConvertNullTo("") which was annoying).