Seq File Delimiter

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Seq File Delimiter

Post by reddy »

Hello Sirs,

I have a Sequential file with some fields delimiter vertical bar and few fields with vertical and double quotes,How to handle it.

Please advice me.

Thanks
Narasa
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since the sequential file stage only allows one delimiter you can't do it in just one step.

I would write a job that defines this sequential file as having one column and no field delimiters at all. Run this stream through a transform that does a REPLACE of all pipe and single-quote characters into double quote characters. The transform output goes to a sequential file which is written to as one column and no field delimiters.

Then have a stream coming out of this sequential file stage with the double quote character as delimiter and with the correct column definitions. You can also make this file stage a pipe for performance (that way, no data is actually transferred to and from the disk).

This solution assumes that you don't have occurrences of pipe and single-quote in the data itself.
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Post by reddy »

ArndW wrote:Since the sequential file stage only allows one delimiter you can't do it in just one step.

I would write a job that defines this sequential file as having one column and no field delimiters at all. Run this stream through a transform that does a REPLACE of all pipe and single-quote characters into double quote characters. The transform output goes to a sequential file which is written to as one column and no field delimiters.

Then have a stream coming out of this sequential file stage with the double quote character as delimiter and with the correct column definitions. You can also make this file stage a pipe for performance (that way, no data is actually transferred to and from the disk).

This solution assumes that you don't have occurrences of pipe and single-quote in the data itself.

Hi Andrew,

Thanks for quick response.

How to convert pipe and double quotes into single quote using a single function.

Thanks for help.
Narasa
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Reddy,

the function would be CONVERT("'|","''",In.BigColumn). Please note the string delimiter in the first parameter is a double quote and the second paramater uses a single quote. This function takes all occurrences of ' and | and replaces them with " and " respectively in the string In.BigColumn
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Maybe you also have to replace your quote char to some other value than dquotes.
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

I agree with Sainath, the best option would be to use a character, thats very unlikely to appear as data in your file. May be ~ or `
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

Just a feeling, are you sure that you are getting two types of delimeter?
Coz, I have a feeling that it could be Quote Character as double quotes and pipe as delimeter.
Shantanu Choudhary
Post Reply