Splitting the row

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
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Splitting the row

Post by dodda »

Hello

I have a requirement where i will be getting the row such as

1234^;abcdefgh^;bc^;d^;efg^;rghu^;klmn^;bcd

each field delimited by ^;

Is there a way that i can extract each field by using Field function.

I tired using the Field function but it didnt work .Earlier they used the single Field separator (;) but noe they came up with field separator as (^;).

Does the Filed function work?

thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The Field function works fine but it does require a single character delimiter, just like the way the Column Import stage does. So you have at least two choices that comes to my mind.

1. Pre-process the file to change all occurrences of those two characters to a single character that you are certain does not occur otherwise in the data.

2. Pick one of the two characters as the Field() delimiter and then trim the other from the data. So, if you used "^" as the delimiter, you'd need to trim any leading ";" from the data the Field function retrieved. Of course, this assumes that you would never find a "^" by itself as data.

This has been discussed before, so I'm sure there's other good advice already out there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Why do you want to extract using field() and not define them as seperate fields in the metadata ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

They would except for the fact that multi-character delimiters are not supported.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Have you investigated using the Field Delimiter String property in the sequential file stage?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

D'oh! I looked at the "Delimiter" property and it had as an option "<other> => A single ASCII character". I didn't see the "Delimiter String" property. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Worth logging in today, then, wasn't it? The same thing applies at the record level - to specify DOS-style (two-character) record delimiter, you need to replace Record Delimiter property with Record Delimiter String property.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right, know about the DOS record delimiter, just forgot about the field delimiter string as an option. Am I missing something with the Column Import stage as well, does it have the same 'delimiter string' option? Not somewhere where I can check tonight.
-craig

"You can never have too many knives" -- Logan Nine Fingers
algfr
Participant
Posts: 106
Joined: Fri Sep 09, 2005 7:42 am

Post by algfr »

Is that resolved ?
ragasambath
Participant
Posts: 12
Joined: Wed Oct 03, 2007 9:11 am
Location: London

Re: Splitting the row

Post by ragasambath »

dodda wrote:Hello

I have a requirement where i will be getting the row such as

1234^;abcdefgh^;bc^;d^;efg^;rghu^;klmn^;bcd

each field delimited by ^;

Is there a way that i can extract each field by using Field function.

I tired using the Field function but it didnt work .Earlier they used the single Field separator (;) but noe they came up with field separator as (^;).

Does the Filed function work?

thanks

Hello dodda,

A Simple work around , replace ^; using UNIX tr or sed command with ; character
You can execute these command using in build Before Sub routines ExecSH

Thanks
Regards

Raga
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No 'workaround' needed when the stage supports reading a file like this via the Delimiter String property.
-craig

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