delimiter of 2 characters in file

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
evanmaas
Charter Member
Charter Member
Posts: 60
Joined: Tue Apr 22, 2003 5:19 am
Location: Belgium

delimiter of 2 characters in file

Post by evanmaas »

Hi,

I have a file that contains delimiters of 2 characters (e.g. ||).

How can I read this file because DS Designer accept only a delimiter of 1 character?

Kind Regards,

Erik
ashwin141
Participant
Posts: 95
Joined: Wed Aug 24, 2005 2:26 am
Location: London, UK

Re: delimiter of 2 characters in file

Post by ashwin141 »

evanmaas wrote:Hi,

I have a file that contains delimiters of 2 characters (e.g. ||).

How can I read this file because DS Designer accept only a delimiter of 1 character?

Kind Regards,

Erik
Hi Eric

You mean you have records like a||b||c||123||d||
Did you try specifying || as delimiter?
Other way out is that you change the || to | in your file and then read it.

Please let us know which one works.

Regards
Ashwin
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Re: delimiter of 2 characters in file

Post by dprasanth »

evanmaas wrote:Hi,

I have a file that contains delimiters of 2 characters (e.g. ||).

How can I read this file because DS Designer accept only a delimiter of 1 character?

Kind Regards,

Erik
There is one way of doing it.. but is a round about way.

Say you have three fields
a||b||c

Now when u define the table defn for the file, give the delimiter as |
Now u can defined the column defns as
col1
del1
col2
del2
col3
del3
So when u read this file, del1, del1,del3 will be '|'. Now you can use the fields you want.
tiagogen
Participant
Posts: 22
Joined: Sun May 14, 2006 2:03 pm
Location: Valinhos

Use a unix command

Post by tiagogen »

You can use a filter command: sed(unix command) to replace 2 delimiters to 1

Let's pretend your delimiter is "||" and you want to replace it to "|". Your filter command will be:
sed "s/||/|/g"
Tiago
evanmaas
Charter Member
Charter Member
Posts: 60
Joined: Tue Apr 22, 2003 5:19 am
Location: Belgium

Re: delimiter of 2 characters in file

Post by evanmaas »

ashwin141 wrote:
evanmaas wrote:Hi,

I have a file that contains delimiters of 2 characters (e.g. ||).

How can I read this file because DS Designer accept only a delimiter of 1 character?

Kind Regards,

Erik
Hi Eric

You mean you have records like a||b||c||123||d||
Did you try specifying || as delimiter?
Other way out is that you change the || to | in your file and then read it.

Please let us know which one works.

Regards
Ashwin
You can not specify || as delimiter.
ashwin141
Participant
Posts: 95
Joined: Wed Aug 24, 2005 2:26 am
Location: London, UK

delimiter of 2 characters in file

Post by ashwin141 »

Thanks alot, never tried that :)

Well what Tiago suggested, is a good way of doing the change in file and then processing it.

Ashwin
JeroenDmt
Premium Member
Premium Member
Posts: 107
Joined: Wed Oct 26, 2005 7:36 am

Re: delimiter of 2 characters in file

Post by JeroenDmt »

evanmaas wrote:Hi,

I have a file that contains delimiters of 2 characters (e.g. ||).

How can I read this file because DS Designer accept only a delimiter of 1 character?

Kind Regards,

Erik
If they're both the same separator like in ||, you could use | as a separator and use every other field for the further processing
bcarlson
Premium Member
Premium Member
Posts: 772
Joined: Fri Oct 01, 2004 3:06 pm
Location: Minnesota

Re: delimiter of 2 characters in file

Post by bcarlson »

ashwin141 wrote:Thanks alot, never tried that :)

Well what Tiago suggested, is a good way of doing the change in file and then processing it.

Ashwin
Just a word of warning - be careful of null fields. What if you have 'a||b||||d' (where the c column is actually null)? The input implies 4 columns, but if all double-delimiters get converted you could end up with 'a|b|d' and have lost the actual 3rd column.

Just something to keep in mind. Make sure your sed command works as expected in all test cases before implementing.

Brad
Post Reply