View previous topic :: View next topic
|
Author |
Message |
pema_yozer
New User
![](images/gallery/cartoon/364.gif)
Joined: 16 Feb 2009 Posts: 54 Location: pune
|
|
|
|
I have a file where there are some is some text (one in every line) in double quotes, i need to create a new file with only the text within these double quotes and concatenate a text in front .
Example:
Input File
Hello this is "AAAAAA"
Hello this is "BB"
The output i want is
TEST AAAAAA
TEST BB
The word test followed by what ever is in quotes |
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
Joerg.Findeisen
Senior Member
![](images/avatars/5413505725e7d861def4c9.jpg)
Joined: 15 Aug 2015 Posts: 1295 Location: Bamberg, Germany
|
|
|
|
Sample:
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=60)),
BUILD=(C'TEST ',%01))
END |
Adjust length to your requirement, and look up PARSE in the manual. |
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
Joerg.Findeisen
Senior Member
![](images/avatars/5413505725e7d861def4c9.jpg)
Joined: 15 Aug 2015 Posts: 1295 Location: Bamberg, Germany
|
|
|
|
You can also omit the IFTHEN and start straight with PARSE in this case. As RECFM was not mentioned, a fixed format is assumed. |
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
sergeyken
Senior Member
![](images/avatars/143067033563aaeccdae6df.jpg)
Joined: 29 Apr 2008 Posts: 2088 Location: USA
|
|
|
|
Joerg.Findeisen wrote: |
Sample:
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=60)),
BUILD=(C'TEST ',%01))
END |
Adjust length to your requirement, and look up PARSE in the manual. |
Highly likely, in the real world parameter SQZ needs to be added, too.
Code: |
OPTION COPY
INREC PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=60)),
BUILD=(C'TEST ',%01,SQZ=(SHIFT=LEFT,MID=C' '))
END |
One more option:
Code: |
OPTION COPY
INREC FINDREP=(INOUT=(C'"',C' '))
END |
|
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
Joerg.Findeisen
Senior Member
![](images/avatars/5413505725e7d861def4c9.jpg)
Joined: 15 Aug 2015 Posts: 1295 Location: Bamberg, Germany
|
|
|
|
FINDREP is a nice addition here, thanks ![icon_exclaim.gif](images/smiles/icon_exclaim.gif) |
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
Rohit Umarjikar
Global Moderator
![](images/avatars/9945761725c07e82d150f2.jpg)
Joined: 21 Sep 2010 Posts: 3068 Location: NYC,USA
|
|
|
|
May be another way - ALTSEQ. |
|
Back to top |
|
![](templates/skyLineGrey/images/spacer.gif) |
|