On Thu, 24 Dec 2015 10:02:35 -0500, Richards, Robert B. wrote:
>You have an *IBM rep*? <grin>
>
>I also wish that the HOLDs file was in a format that could easily be imported
>into EXCEL so that I could use filtering criteria.
>
Heres a hack at converting HOLDDATA to CSV. (I left out the hard part:
parsing the COMMENT(...) )
#! /bin/sh
# Doc: convert IBM HOLDDATA (Argument or stdin) to CSV.
# Bug: Doesn't parse COMMENT correctly.
awk 'BEGIN {
KN = split( "WHAT HOLD FMID WHY REASON CLASS SYMP DATE COMMENT", KL )
Sep = ""; for ( I = 1; I<=KN; I++ ) {
printf( "%s", Sep KL[ I ] )
Sep = ", " }
print( "\n-----" ) }
function PutKey( key, val ) {
gsub( /\"/, "\"\"", val )
if ( match( val, /[,"]/ ) ) val = "\""val"\""
A[ key ] = val }
function ParseOpts() {
sub( /^ \+\+ */, "", Buffer )
sub( /[ .]*$/, " ", Buffer )
PutKey( "CLASS", "n/a" )
PutKey( "SYMP", "n/a" )
while ( Buffer ) {
match( Buffer, / / )
KV = substr( Buffer, 1, RSTART - 1 )
Buffer = substr( Buffer, RSTART )
sub( /^ */, "", Buffer )
K = KV
if ( sub( /\(.*/, "", K ) ) {
sub( /[^(]*\(/, "", KV )
sub( /\)$/, "", KV ) }
else K = "WHY"
if ( K=="RELEASE" ) {
PutKey( "WHAT", "Rel" )
PutKey( "HOLD", KV ) }
if ( K=="HOLD" ) {
PutKey( "WHAT", "Hold") }
PutKey( K, KV ) }
}
function DumpBuff() {
split( "", A ) # Clear work array.
sub( /[ .]$/, " ", Buffer ) # Remove terminating "."; append one space.
B = Buffer
sub( /^[^(]*\(/, "", B )
sub( /\).*/, "", B )
ParseOpts()
Sep = ""; for ( I = 1; I<=KN; I++ ) {
printf( "%s", Sep A[ KL[ I ] ] )
Sep = ", " }
print( " " )
}
/^\+\+ *NULL/ { next }
/^\+\+/ {
if ( Buffer ) DumpBuff()
Buffer = "" }
{ Buffer = Buffer" "substr( $0, 1, 72 )
sub( / *$/, "", Buffer ) }
END { DumpBuff() }
' "$@"
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN