Surrounding data with double quotes for a CSV file

Hi,
I’m using Clover’s Java API to write into a CSV file using the DELIMITED_DATA_WRITER component. Is there any way to enforce Clover to surround all data values including Date, Integer, Double etc with a double quote?

I have a REFORMAT component that does some formatting prior to the execution of the DELIMITED_DATA_WRITER component. I have been able to use this component to successfully surround the String values with double quotes, but not the other data types. If I do so, it understandably throws a BadDataFormatException since it is of type java.util.Date. Is there a way to do it via Clover’s API otherwise?

I’m using Clover’s 2.7.2 API.

Thanks in advance!
Pramod

Hello Pramod,
I see two solutions of your problem:

  • Output metadata from Reformat node contains only string data field with quoted values

  • Use StructureWriter instead of Universal or Delinited Data Writer, with body mask like “$field1”,“$field2”,“$field3”…

Thanks Agata!
I was able to fix my problem successfully with the StructureWriter.

But I’ve just one clarification, do I need to explicitly specify a record delimiter (a new line in my case) while specifying the mask? or is there a way i can tell the StructureWriter to put a new line after every record it writes?

Since I’m using it to write CSV files, I’m currently specifying the mask as

"$field1","$field2",....,"$fieldn"\n

to get it to write every record on a new line.

Thanks,
Pramod.

Hello Pramod,
you are right - the record delimiter must be specified in the mask. There is no other way to put in to the file. If you suppose that the graph can run on various systems use parameter for it:

"$field1","$field2",....,"$fieldn"${rec_delimiter}