Page 1 of 1

Parse Data

Posted: Mon Nov 21, 2011 8:23 am
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

Posted: Mon Nov 21, 2011 9:25 am
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

Parse data

Posted: Mon Nov 21, 2011 9:27 am
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..

Parse Data

Posted: Mon Nov 21, 2011 9:38 am
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

Posted: Mon Nov 21, 2011 9:41 am
by ShaneMuir
I know. Try the code above in the output column derivation.

Parse data

Posted: Mon Nov 21, 2011 10:03 am
by pavan_test
Thank You. The code worked.

Posted: Mon Nov 21, 2011 10:08 am
by ShaneMuir
Keep in mind that that code will only work for that specific pattern.

Posted: Mon Nov 21, 2011 10:24 am
by qt_ky
Will that code work on a record like this?

a1.2Mb3.4Lc5.6X

Posted: Mon Nov 21, 2011 10:37 am
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.