Reading a record from Tab delimited sequential 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
bharathappriyan
Participant
Posts: 47
Joined: Fri Sep 23, 2005 6:01 pm

Reading a record from Tab delimited sequential file

Post by bharathappriyan »

Hi,
I am having a sequential file which is Tab delimited.
The records in the file is as follows:
Rec# AcNo Value1 Value2 Value3 Value4
1 100 111 112 113 114
2 200 211 212 213 214
3 300 311 312
313 314
4 400 411 412 413 414
5 500 511 512 513 514
6 600 611 612
613 614

For the 3rd record, the value of value3 column is moved into next line instead of being in the same line and that column and the remaining columns are Null for this record. Because of this problem,
the fourth row is treated as 4th column while reading which is having the AcNo as Null. But the actual 4th record AcNo is 400.
I want the data of the 4th row should be treated as 3rd record while reading.
Please help me how to handle this stalemate situation.
Thx in Advance.

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

Post by chulett »

That doesn't seem to be a 'tab delimited' read problem - are you saying that your file is messed up and there is a CR in the middle of record 3? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Post by Sunshine2323 »

Hi bharathappriyan,

Your Input:

Field1,Field2,Field3,Field4,Field5,Field6
1 100 111 112 113 114
2 200 211 212 213 214
3 300 311 312
313 314
4 400 411 412 413 414
5 500 511 512 513 514
6 600 611 612
613 614

Your file is messed up and you will have to correct it by getting the 4th row up to the 3rd row.

If this is your requirement then you can try the below method to try to correct your input file

<Step 1>
Declare Stage Variables:
StageVar1 = IF IsNull(DSLink2.Field3) THEN StageVar2:',':DSLink2.Field1:',': DSLink2.Field2 ELSE ''

StageVar2 = If IsNull(DSLink2.Field5) AND Not(IsNull(DSLink2.Field4)) THEN DSLink2.Field1:',': DSLink2.Field2:',': DSLink2.Field3:',': DSLink2.Field4 ELSE ''

<Step 2>
Define Transformer Constaint as Len(StageVar2)=0

<Step 3>
Your Input file has one column
OutputField=if Len(StageVar1)>1 then StageVar1 else DSLink2.Field1:',':DSLink2.Field2:',':DSLink2.Field3:',':DSLink2.Field4:',':DSLink2.Field5:',':DSLink2.Field6

Now browse to the location where this output file is located and open it and you will see the output as

1,100,111,112,113,114
2,200,211,212,213,214
3,300,311,312,313,314
4,400,411,412,413,414
5,500,511,512,513,514
6,600,611,612,613,614

You can use a Sequential File stage to read the data correctly

If you do not want ',' as the delimiter then you can replace the delimiter in the above code with your required delimiter.

Hope this helps :)
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Scroll right in the Columns grid. You will find a setting called something like "contains terminators" that may help.
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 »

You may also find that manually editing the file helps tremendously. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

chulett wrote:You may also find that manually editing the file helps tremendously. :wink:
:lol:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply