View previous topic :: View next topic
|
Author |
Message |
pema_yozer
New User

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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2173 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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 Location: Bamberg, Germany
|
|
|
|
FINDREP is a nice addition here, thanks  |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3083 Location: NYC,USA
|
|
|
|
May be another way - ALTSEQ. |
|
Back to top |
|
 |
|