View previous topic :: View next topic |
Author |
Message |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Fri Jun 24, 2011 5:20 am Post subject: Sort records between the multiple headers & traders. |
|
|
I have a requirement to build a sort card. Can anyone help in this to build a sort card
Requirement:-
Input File :-
Code: |
A00001
C00002
B00002
B00001
B00009
B00006
D00001
D00002
|
Output file:-
Code: |
A00001
C00002
B00001
B00002
B00006
B00009
D00001
D00002
|
All the records which start with B should be sorted and the remaining records from the input file should be copied same to the output file. If we consider all other records which are not starting B as headers & trailers i.e. (multiple headers & trailers). The header & trailers are not constant as shown in below
Example1
Input File
Code: |
A00001
A00002
C00001
C00002
B00002
B00001
B00009
B00006
D00001
D00002
D00003
D00004
|
Output file
Code: |
A00001
A00002
C00001
C00002
B00001
B00002
B00006
B00009
D00001
D00002
D00003
D00004
|
Example2
Input file
Code: |
A00001
B00002
B00001
D00001
|
Output file
Code: |
A00001
B00001
B00002
D00001
|
Thanks,
Siva |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Sat Jun 25, 2011 1:51 pm Post subject: |
|
|
Thanks kolusu..
I have tried with DATASORT. It works fine when i already know that there are this many header & trailer present in the file.. the problem here is that the no of header & trailer are not constant. i want a sort it would handle multiple headers & trailers and sort the details records.
Thanks,
Siva |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Jun 25, 2011 11:59 pm Post subject: |
|
|
sivafdms,
Well you should have looked at sorting groups of records using when=group instead of datasort. Either way if your data has A, B, D in the first byte, isn't it a simple sorting on that ? You need to post better examples of data if you need help from us. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|