* Each line contains one record for a dataset.
* Each line contains the data for only one Name variable and one Amount variable at the fix position.
* Based on the value of first variable(Type), the next values should get assigned to the corresponding variables as follow -
Type A --> Name1, Amout1 (rest all the variables in the dataset will be null)
Type B --> Name2, Amout2 (rest all the variables in the dataset will be null)
Type C --> Name3, Amout3 (rest all the variables in the dataset will be null)
* The datalines are shuffled and not in sequence of A,B,c compulsarily.
* The no. of dataliens are in millions.
The final dataset must look like -
Row# Type Name1 Name2 Name3 Amount1 Amount2 Amount3
1 A John 1000
2 B Mac 1200
3 C Amar 1100
4 B Jack 1300
5 B Maria 1200
6 A Meg 1400
7 C Rohan 1000
In order to achieve above requirement, I have used the trailing "@" feature in the following code which is working quite ok.
Input Type $1 @;
If Type = "A" then
Input Name1 $ Amount1;
If Type = "B" then
Input Name2 $ Amount2;
If Type = "C" then
Input Name3 $ Amount3;
Just want to confirm it it is the only option to deal with such scenario. Considering the processing of million records, is there any other better alternative to achieve the above task.
Any help regarding this will be highly appreciated.
This chaning-style row structure can only be imported in the way you discribe. I can just add a little change to your program, saving a few seconds on running time : change the IF to a SELECT statement.
Input Type $1 @;
SELECT (type) ;
WHEN("A") Input Name1 $ Amount1;
WHEN("B") Input Name2 $ Amount2;
WHEN("C") Input Name3 $ Amount3;
OTHERWISE INPUT ;