|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help needed with Korn Shell scripting
We receve pipe delimited file with
transaction ID,tran_date,Quest_cd,Ans_cd,ans_value. Same transaction ID can be repeated with different quest_cd and ans_cd. Basically I need to check if a perticular pair of quest_cd and ans_cd (say Q1234,A1234) is present under a transaction ,then another pair of quest_cd and ans_cd (say Q5678,A5678) should also be present. Otherwise I need to remove the isolated row from input file and write to a bad file which should have the complete row in defect and with a comment that Q1234A1234 present but Q5678A5678 not present Or vice versa. I am giving few lines of my file: 991320070521330000000003|Q13251|A18741|234567890123456 671320070521330000000003|Q13251|A18741|456787654328977 671320070521330000000003|Q13260|A18765|4567890987654321234 471320070521330000000003|Q13260|A18765|2345678901234561 In the above the two lines with transaction ID 671320070521330000000003 should be written to a good file as they are having both pairs of Q/A and the other should be written to bad file with comments like below: 991320070521330000000003|Q13251|A18741|234567890123456 --> ONLY Driver's Licence is present Credit card number missing 471320070521330000000003|Q13260|A18765|2345678901234561 --> ONLY Credit card number is present Driver's Licence missing The reason why the two lines with transaction id 671320070521330000000003 should be written to a good file is that they are having both the Q/A pairs ie.Q13251|A18741 and Q13260|A18765 while the other transactions are having either of these pairs but not both the pairs Thanks Sri |
|
#2
|
|||
|
|||
|
For examples have only 4 fields even though you say there are 5 fields i.e
transaction ID tran_date Quest_cd Ans_cd ans_value Humm, this could be a nightmare to run unless the file is sorted. I would sort the file on the transaction ID, then read in the file a line at a time, save line to temporary variables read next line it, compare with temporary variables and do the necessary depending on whether you get a match or not. |
|
#3
|
|||
|
|||
|
Hi
It is my mistake .Transaction date was not there in the example.You can treat this as 4 fields. The file is already sorted.I need the code to the action you suggested as I am new to UNIX and it looks complicated for me. I hope you can help me Thanks SRi |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Help needed with Korn Shell scripting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|