View previous topic :: View next topic
|
Author |
Message |
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi All,
I have records of length 80 with the following text which I would like to split into 3 columns of widths 25, 24 and rest into the third column delimited by PIPE.
Can someone suggest me the DFSORT code for this?
Code: |
[b]Input[/b]
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000100 RELIANCE INDUSTRIES LIMITED MAIN BRANCH MUMBAI POWAI
000200 RELIANCE COMMUNICATIONS, ABCD ROAD, BANGALORE
000300 LUPIN PHARMA LIMITED, STREET NO. 1 MYSORE,
000400 TATA CONSULTANCY SERVICES| LIMITED, DOMESTIC, MADHAPUR
000410
|
Code: |
[b]Output[/b]
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000500 RELIANCE INDUSTRIES |LIMITED MAIN BRANCH |MUMBAI POWAI
000600 RELIANCE COMMUNICATIONS, |ABCD ROAD, BANGALORE |
000700 LUPIN PHARMA LIMITED, |STREET NO. 1 MYSORE, |
000800 TATA CONSULTANCY SERVICES| LIMITED, DOMESTIC, |MADHAPUR
|
Rec # 1: To split the text after 25 chars, the word LIMITED is going to disturb. so the split should happen at the SPACE before the position 26
Rec # 2: New word ABCD starts at pos 26, Previous pos 25 is a SPACE. So, split happened there
Rec # 3: Same as Rec # 1
Rec # 4: The word SERVICES ended at pos 25 and there is a SPACE at pos 26, PIPE added at pos 26 and the SPACE moved to the next column. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Please don't aim your posts at unsolicited individuals.
It can be done, but it is a lot of code compared to a program written in a general-purpose language.
If you need something before the weekend, use a general-purpose programming language. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
@Bill Woodger,
Yes, I have started writing a program as well for this. Thanks for your response. Will wait for further responses ... |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
I too would opt for a program.
Which language do you use? |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
@ Marso,
I'm using COBOL proram. |
|
Back to top |
|
|
|