Parse data

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
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Parse data

Post by vinaymanchinila »

Hi,
I am reading from a table and one of the columns has the following sample data, I need to parse the data and extract 3 fields , the delimiter is '-'

Source: 205-51-510203 Required Output: 205 51 510203
Source: 201-1-10001 Required Output: 201 1 10001
Source: 202-14 Required Output: 202 14
Source:207 Required Output: 207


Any ideas, I am trying to use the Field function.

Thanks,
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use convert.

Code: Select all

CONVERT("-", " ", in.Col)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi,

I am not trying to repalce the '-', I need to parse or extract 3 columns from one , if it is 12-34-5, then I need 12, 34 and 5 as separate column values.

Thanks,
Thanks,
Vinay
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

I have got this to work using the Field function, thanks !
Thanks,
Vinay
swades
Premium Member
Premium Member
Posts: 323
Joined: Mon Dec 04, 2006 11:52 pm

Post by swades »

One more option is Load to Flat file,while reading that file define "-" as delimiter.I guess its work.
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Post by sshettar »

i guess this could also be done in just the sequential file stage by specifying the properties

Record level

Final delimiter = end

Field Defaults

Delimiter = -
Quote = none

and in columns tab specify your metadata ( ie 3 columns)

i think this should work .

correct me if i'm wrong
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

It might, but no need to land it to a flat file. It can be taken care of in the transformer itself.
vinaymanchinila , the sample data and output that you provided gave me the impression that the hypen (-) needs to be replaced with a space and hence my resolution. Had you made it clear in your original post that the output needs to go into 3 different columns, the solution would have been different. Anywho, glad you got it working. Care to share the solution for future searchers ???
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi,
I have used the Field function, my source column has 3 values delimited by '-' and I needed 3 output columns , the following are the derivations for the 3 output columns,

SourceCol=201-232-9090


Output Col1=201 ---->Field(SourceCol,'-',1)
Output Col2=232---->Field(SourceCol,'-',2)
Output Col3=9090---->Field(SourceCol,'-',3)

Thanks,
Post Reply