ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DFDL Double Quotes for NULL or any value for CSV

Post new topic  Reply to topic
 DFDL Double Quotes for NULL or any value for CSV « View previous topic :: View next topic » 
Author Message
18tillidie
PostPosted: Tue Jul 21, 2020 6:57 am    Post subject: DFDL Double Quotes for NULL or any value for CSV Reply with quote

Newbie

Joined: 04 May 2020
Posts: 9

Hi I am new to IIB,

Need help in sending "" (double quotes in case the value is NULL, or any value with double quotes.)

I have 2 DFDLs created Input and Output I am using the below code to map and generate .csv output file. I need to send double quotes in case the SET value is NULL and I am using the below code.


SET refToOutput.TEST_DFDL[i].Name=COALESCE(reftoInput.Name,'""');

This shows as """""" in output when I send single double quote I get """"

OR for any value

SET refToOutput.TEST_DFDL[i].Doc_NBR=COALESCE(reftoInput.FileNum,'"TRY"');

Output for this is getting generated as """TRY""" instead of "TRY"

Any help would be much appreciated.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jul 21, 2020 7:10 am    Post subject: Re: DFDL Double Quotes for NULL or any value for CSV Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

18tillidie wrote:
Hi I am new to IIB,

Need help in sending "" (double quotes in case the value is NULL, or any value with double quotes.)

I have 2 DFDLs created Input and Output I am using the below code to map and generate .csv output file. I need to send double quotes in case the SET value is NULL and I am using the below code.


SET refToOutput.TEST_DFDL[i].Name=COALESCE(reftoInput.Name,'""');

This shows as """""" in output when I send single double quote I get """"

OR for any value

SET refToOutput.TEST_DFDL[i].Doc_NBR=COALESCE(reftoInput.FileNum,'"TRY"');

Output for this is getting generated as """TRY""" instead of "TRY"

Any help would be much appreciated.


So what happens if you use:
Code:
SET refToOutput.TEST_DFDL[i].Doc_NBR=COALESCE(reftoOpGtInput.FileNum,'TRY');

Have you tried it ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
18tillidie
PostPosted: Tue Jul 21, 2020 7:12 am    Post subject: Reply with quote

Newbie

Joined: 04 May 2020
Posts: 9

'TRY' comes out as only TRY I need it in double quotes.
Back to top
View user's profile Send private message
18tillidie
PostPosted: Tue Jul 21, 2020 7:15 am    Post subject: Reply with quote

Newbie

Joined: 04 May 2020
Posts: 9

18tillidie wrote:
'TRY' comes out as only TRY I need it in double quotes.


Forgot to mention I am opening the csv file in notepad ++
Back to top
View user's profile Send private message
timber
PostPosted: Tue Jul 21, 2020 8:01 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

When writing delimited data like CSV, the DFDL 'escape scheme' comes into play. CSV formats use a standard escape scheme that works like this:
- normal values are output unchanged
- values that contain a comma or a line-end character get escaped by putting double quotes around the value.
- empty string values are not[ escaped with "". They just result in two commas together.
These rules are as close as you will get to an industry-standard for CSV.

You can tweak the escape scheme settings, but I don't know if you will be able to achieve exactly what you are trying to do. Are you
a) trying to represent an empty string as "", but other values without quotes
b) trying to put quotes around all values
c) something else
Back to top
View user's profile Send private message
18tillidie
PostPosted: Tue Jul 21, 2020 9:51 am    Post subject: Reply with quote

Newbie

Joined: 04 May 2020
Posts: 9

Issue Resolved, Thank you @timber owe you

Went to the DFDL - http://www.ibm.com/dfdl/CommaSeparatedFormat >> Schema location in the Library project >> opened with DFDL editor >> Under Representation Properties changed values for Escape Block Start and Escape Block End from " to ,

Deployed and tested code it worked like a charm. Thanks again. I LOVE MQSERIES.NET.
Back to top
View user's profile Send private message
timber
PostPosted: Tue Jul 21, 2020 3:06 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Thanks for the feedback. I hate to say this, but I don't think that's anywhere near the correct solution. In fact, I would be surprised if it outputs the correct number of commas in all circumstances.
The problem is, the Escape Block Start is definitely NOT a delimiter. But the comma definitely is. Arguably, the DFDL validator should complain about using a comma in the EBS property.

Also, less seriously, you have edited the global settings for DFDL. The correct way to do it would be to declare your own Escape Scheme (by copying the one in the IBM-supplied schema) and apply your own settings there. Then adjust the 'default format block' in your own schema to point at it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DFDL Double Quotes for NULL or any value for CSV
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.