View previous topic :: View next topic
|
Author |
Message |
Markandeyulu
New User
Joined: 27 May 2010 Posts: 10 Location: Chennai
|
|
|
|
Hi,
Can we sort the records based on the record length?
For example:
In my input -
Code: |
abcdefghijklmnopqrstuvwxyz
abcdefghijklmno 1 111
abcdefghijklmnopqrstu
abcdefghijklmnopqrstu12345
abcdefghijkl |
So the above mentioned records should be sorted based on the length, i.e. the output should be like:
Code: |
abcdefghijkl
abcdefghijklmnopqrstu
abcdefghijklmno 1 111
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstu12345 |
Please suggest me with the solution. Thanks in advance. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
If the file is a VB file, very easily as bytes 1-2 of a VB file is the binary record length.
If it is a FB file, I can only think of converting to a VB file and then sorting as above.
But, I am sure that if it can be done any easier then the DFSORT guys will show us how |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Markandeyulu,
As expat mentioned you can sort on the first 2 bytes of RDW if the input file is a VB File. If the file is FB then you need to convert to vb and strip off the trailing blanks and then sort.
However you output doesn't make sense. take a look at the 2 records below. Both records are of the same length and how did your output has 111 record end up at the bottom? Both records have a length of 21 bytes and the first 15 bytes are the same. For the 111 record the 16th byte is a space and the other record has P. Technically if you sort it ascending , the space record comes first followed by P record.
Code: |
----+----1----+----2--
ABCDEFGHIJKLMNO 1 111
ABCDEFGHIJKLMNOPQRSTU
|
So you need to explain the rules for sorting along with DCB properties of the input and output files. |
|
Back to top |
|
|
|