IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Help in extracting data between double quotes


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Thu Jul 20, 2023 5:02 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Thu Jul 20, 2023 5:38 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Thu Jul 20, 2023 10:42 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Fri Jul 21, 2023 12:55 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri Jul 21, 2023 1:49 am
Reply with quote

FINDREP is a nice addition here, thanks icon_exclaim.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Sat Jul 22, 2023 8:41 am
Reply with quote

May be another way - ALTSEQ.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top