You can use the OMIT feature to drop the trailer record

You can use the IFTHEN feature to recognize whether the current record is a
header record or data record.

For the data records, you can simply copy starting at column 6.  Because the
records are VB, you specify column 10 to account for the RDW.

You can use the PARSE feature to extract the 7 column titles from the header
record.  Using comma as your delimiter, find the word FIELD; extract the
next word; repeat 6 more times.  Use the 7 extracted words to build your new
header.

:>: -----Original Message-----
:>: From: IBM Mainframe Discussion List [mailto:[email protected]] On
:>: Behalf Of Bill Ashton
:>: Sent: Wednesday, May 07, 2014 9:28 AM
:>: To: [email protected]
:>: Subject: Use SORT to manipulate a CSV?
:>:
:>: Hi friends...you have been helpful to in so many areas so far, and now I
:>: have a question about using SORT.
:>:
:>: I have an application that creates a CSV file (sort of) on the
mainframe.
:>: The data rows start with a field "DATA" before the actual data fields,
:>: and
:>: there is a Header row that has a lot more than the column names, and a
:>: single trailer row I want to drop.
:>:
:>: I have never used SORT to work with the concept of fields before, and am
:>: not sure if this can be done, but would appreciate if someone might lend
:>: a
:>: hand. The file is a VB file with LRECL=0 and BLKSIZE=4096. Here is what
:>: the
:>: data records look like:
:>:
:>: DATA,1,"A","S",3000.00,25000.00,23000.00,78000.00
:>: DATA,17,"A","S",1000.00,10000.00,15000.00,26000.00
:>: DATA,24,"A","S",1000.00,8500.00,11500.00,26000.00
:>: DATA,30,"A","S",975.00,9000.00,5500.00,25350.00
:>: DATA,26,"A","S",950.00,7900.00,11000.00,24700.00
:>: DATA,31,"A","S",925.00,7500.00,6000.00,24050.00
:>:
:>: I want to drop the first field and comma, so the output should look like
:>: this:
:>: 1,"A","S",3000.00,25000.00,23000.00,78000.00
:>: 17,"A","S",1000.00,10000.00,15000.00,26000.00
:>: 24,"A","S",1000.00,8500.00,11500.00,26000.00
:>: 30,"A","S",975.00,9000.00,5500.00,25350.00
:>: 26,"A","S",950.00,7900.00,11000.00,24700.00
:>: 31,"A","S",925.00,7500.00,6000.00,24050.00
:>:
:>: Then, the 1st record header looks like this:
:>: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
:>: --+----8----+----9----+----0
:>: HEADER,MYVAR,DETAIL,050714,091407,RECORD,PAYROLL,PAY,001,FIELD,NUMBER,N,
:>: 005,00,N,FIELD,ACTIVITY-CODE...
:>: (this goes on for the 7 column headers. It appears the field contains
:>: "FIELD" just before the column header
:>: (FIELD,NUMBER,...FIELD,ACTIVITY-CODE,...FIELD,ACTIVITY-STATUS,...), and
:>: the
:>: first "FIELD" field is the 9th field in the record.
:>:
:>: I would really like this header to look like this (I don't think I need
:>: to
:>: add double-quotes, but am not sure how to do that, either!):
:>: NUMBER,ACTIVITY-CODE,ACTIVITY-STATUS,...
:>:
:>: Finally, the trailer looks like this:
:>: TRAILER,0202
:>:
:>: and I want to just drop this record.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to