My input has a unique column-id with the values 10,20,30.....how can i get first record in one o/p file,last record in another o/p file and rest of the records in 3rd o/p file?

Answers were Sorted based on User's Feedback



My input has a unique column-id with the values 10,20,30.....how can i get first record in one o/p f..

Answer / subhash

We can do in this way as well:

In the same job,
SeqFile--->Target1
SeqFile--->Target2
SeqFile--->Target3
for Target1,
add Filter condition in the SeqFile as below:
Head -1

for Target2,
add Filter condition in the SeqFile as below:
Tail -1

for Target3,
add Filter condition in the SeqFile as below:
sed '1,$ d'

Is This Answer Correct ?    8 Yes 2 No

My input has a unique column-id with the values 10,20,30.....how can i get first record in one o/p f..

Answer / kumar

As you have a single text file as Source. Use folloowing
approach to get the desired output.

Head1 Target1

Seq. File Copy Tail2 Target2

Head3 Tail Target3
Steps:
1.> Read your source file using sequential file stage.
2.> Pass the records to copy stage and take 3 output link.
3.> 1 to Head stage head1, 2nd to Head2 and 3rd to Head3.
4.> In the 1st Head Stage Head1, in the properties specify
1, it will pick up the 1st record and make that record to
target 1.

5.> Similarly, to capture last record in target2, in Tail
stage property mention 1. It will take last record and pass
it to target2.

6.> To load rest records 1st using head stage, capture top
records say, if u have 10 records in the source pick top 9
records using head stage then use tail stage followed by
head stage and mention 8, it will pick all records except
1st one. then u can load these to target3.

If u get confused ask me ....

Thanks
Kumar

Is This Answer Correct ?    8 Yes 4 No

Post New Answer

More Data Stage Interview Questions

WHAT ARE THE COMMON ERRORS IN DATA STAGE?

6 Answers   IBM, ME,


Hi guys, please design job for this, MY INPUT IS COMPANY,LOCATION IBM,CHENNAI IBM,HYDRABAD IBM,PUNE IBM,BANGLOORE TCS,CHENNAI TCS,MUMBAI TCS,BANGLOORE WIPRO,HYDRABAD WIPRO,CHENNAI HSBC,PUNE MY OUTPUT IS COMPANY,LOCATION,COUNT IBM,chennai,hydrabad,pune,banglore,4 TCS,chennai,mumbai,bangloore,3 WIPRO,hydrabad,chennai,2 HSBC,pune,1 Thanks

3 Answers   IBM,


insequential file 2header avaliable,and 100 records avaliable.how to skip the 2 headers and load 100 records target?

5 Answers  


What is the use of datastage designer?

0 Answers  


Define data aggregation?

0 Answers  






In my previous project we get data from mainframe and load it into datastage DB2 tables.Sometimes we get data as flat file or a mainframe tables itself directly we fetch the data.Is this a migration project?

1 Answers   TCS,


what is the unix script to run the job? Please mention commands which we use often?

3 Answers   TCS,


HOW CAN WE SEE THE DATA IN DATASET?

12 Answers   IBM, TCS,


how to call routines in stages?

3 Answers   ME,


what is ds administrator used for?

0 Answers  


What is APT_DUMP_SCORE?

2 Answers   IBM,


What are the main features of datastage?

0 Answers  


Categories