webMethods

 View Only

 Creating a Flatfile with every field enclosed in Quotes (or QuotedRelease).

Chirag Sanghavi's profile image
Chirag Sanghavi posted Wed January 08, 2025 12:06 PM

Picking up a very old thread:


efficient-method-to-create-csv-with-double-quotes

Ibm remove preview
webMethods
I was wondering if anyone have an efficient method of creating CSV from IS document that includes header names and the data wrap with double quotes. I suppose
View this on Ibm >

if need is to use WmFlatFile and enclose every field with say quotes.  One of the method suggested by Rob Eamon is to use formatting service. 

It does add few inefficincies:

  1. Additional Service call  for each field
    1. more operations / more memory utilization
  2. Formatting service are involved both for writing and reading
    1. if need is to strip "" during reading - it needs to be applied as QuotedRelease character 
    2. using formatting service and quoted release at same time - doubles the quotes being generated - leading to need for having two Flatfile Schemas - one for read and one for write

Is there a better way of producing flat file where every field needs to be enclosed in a quote? 

As this doesn't allow "reply" to be posted - adding to discussion from Pedro - while I can use direction (that's what we did), issue is that in order to process incoming data - quotedRelease have to be used and if you use formatting service - it "doubles" up on the ""quotes"".

engin sarlak's profile image
engin sarlak

That post is very old. Back in 2009 it might be the only way.

You should be able to create the FF schema from the sample file and while creating it from the sample, you can test what your separators get you at the end. You should be able to parse it by properly setting quoted release character and release character to " and field seperator to whatever the file expects. I am not an FF expert though and there might be additional work depending on your sample file. 

Pedro Dinis Silva's profile image
Pedro Dinis Silva

Hi Chirag,

I've faced a similar issue recently. The way I've found to avoid having two schemas is by making use of the input variable "direction".

In the formatting service spec there is a direction input:

You can branch on this value to decide what you want to do based on if you want to convert to string or values, like this:
You can also override some part of the schema when calling either convertToValues or convertToString.

The only issue I have with this is that if the value in the csv is empty, the formatting service doesn't run. I'm still trying to find a way around that.

Hope this helps.

All the best,
Pedro