Delimiter Handling

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
smile.achieve
Participant
Posts: 15
Joined: Mon Apr 23, 2012 12:28 pm

Delimiter Handling

Post by smile.achieve »

In my parallel job I am writing data to a Sequential stage file. Its a comma delimited file.With all Varchar coloumns in source. As per Seq stage all varchar coloumn data is quote when writtent to file though we have option to remove the quotes. But it should double quote data with comma in it.

In detail

for source col1 col2 col,3 out put should be col1,col2,"col,3"

assuming all the above as varchar how to make sure that only col3 has give double quotes in target file
Smile :)
smile.achieve
Participant
Posts: 15
Joined: Mon Apr 23, 2012 12:28 pm

Post by smile.achieve »

I didnt knew that my english was so poor. Sorry
Smile :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your English was fine, no worries there.

First, why worry about the quotes? They certainly don't hurt so there's no reason that I can see to try and only put them only around values that "need" them. However, I would think you could write out the file without quoted strings and manually add quotes as part of the data when you detect a comma in the field to get that behaviour.
-craig

"You can never have too many knives" -- Logan Nine Fingers
smile.achieve
Participant
Posts: 15
Joined: Mon Apr 23, 2012 12:28 pm

Post by smile.achieve »

My target file is comma separated file .Now i cant distinguish between , in a record and , which is there for as a record separator. hence this requirement.
Smile :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You solve the problem by allowing the stage to quote all string fields. However, I as said, you can get the output you want by handling the quotes yourself. The Index() function can be used to detect the presence of a comma in your data and drive an if-then-else expression to wrap the value in double-quotes only when needed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply