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
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Parse Data

Post by pavan_test »

Hi All,

I have a source file with records such as,

dsadsad 3.6L dsfgfdgfdg
weewqd 2.4L dsdsa
vxcvbvbvbvcvccvc2.8Lfgfdgf

if the data in the source file match the pattern 0.0L then I have to output the data. 0.0L pattern will occur only once per each record.

desired data in the output file:
2.6L
2.4L
2.8L

can someone please suggest me how can I accomplish this.

Thanks..
pavan
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Is there only ever the one decimal point (.)? And is the pattern always 0.0L

If so then something like

Code: Select all

Right(Input['.',1,1],1):'.':Left(Input['.',2,1],2) 
should work
Last edited by ShaneMuir on Mon Nov 21, 2011 9:32 am, edited 1 time in total.
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Parse data

Post by pavan_test »

yes, that is correct. There will be only 1 decimal point. The pattern will always be 0.0L.

And there will be only 1 such pattern in each record. No repetitions or duplicates in the record.

Thanks..
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Parse Data

Post by pavan_test »

Also there will be other data in the column, I have to match the pattern 0.0L and ignore the rest.

saADSDSADSA2.8Lhhgfhgf

desired output: 2.8L

Thanks
Pavan
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

I know. Try the code above in the output column derivation.
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Parse data

Post by pavan_test »

Thank You. The code worked.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Keep in mind that that code will only work for that specific pattern.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Will that code work on a record like this?

a1.2Mb3.4Lc5.6X
Choose a job you love, and you will never have to work a day in your life. - Confucius
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

I guess it would fail because that example has more than one decimal. If the requirements are that narrow, OK. If the data contains other decimals or a.bL or 1.2R instead of 1.2L or in addition to it, then you would need more checks because that logic is based only on locating a single decimal (no other validations). My point is it's not checking for 0-9 on either side and not checking for L after that, so it's not necessarily matching the #.#L pattern.
Choose a job you love, and you will never have to work a day in your life. - Confucius
Post Reply