Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what I was thinking. Put the script into a file and make it executable so it can be run like:</p> <pre><code>script.awk *inputparams.txt </code></pre> <p>The script: #!/usr/bin/awk -f</p> <pre><code>BEGIN { FS="|" OFS="," # $3 field strings arr[ "2==1 3==1" ] = "Subscription Creation without Previous" arr[ "2==1 3==5" ] = "Offer Upgrade" arr[ "2==1 3==6" ] = "Offer Downgrade" arr[ "2==1 3==7" ] = "Campaign Extend" arr[ "2==1 3==8" ] = "Campaign Change" arr[ "2==1 3==27" ] = "Subscription Update" arr[ "2==2 3==2" ] = "Charging Renewal" arr[ "2==2 3==3" ] = "Subscription Reactivation" arr[ "2==2 3==4" ] = "Subscription Reactivation with Recharge Monitoring" arr[ "2==2 3==8" ] = "Campaign Change" arr[ "2==2 3==30" ] = "Limited Service" arr[ "2==3 3==11" ] = "Cancellation" arr[ "2==3 3==17" ] = "Subscriber Account Reactivation" arr[ "2==4 3==11" ] = "Cancellation" arr[ "2==5 3==11" ] = "Cancellation" arr[ "2==5 3==12" ] = "Expiration" arr[ "2==5 3==13" ] = "Inactivation due to Charging" arr[ "2==5 3==14" ] = "Inactivation due to Ceased Account" arr[ "2==5 3==15" ] = "Inactivation due to Payment Method Change" arr[ "2==5 3==16" ] = "Inactivation due to Ownership Change" arr[ "2==5 3==18" ] = "Inactivation due to Offer Upgrade" arr[ "2==5 3==19" ] = "Inactivation due to Offer Downgrade" arr[ "2==6 3==9" ] = "Campaign Schedule" arr[ "2==6 3==10" ] = "Offer Schedule" # $2 field strings arr[ "1==5 2==2" ] = "RENEWAL" arr[ "1==4 2==2" ] = "SUBS. CREATE RENEWAL AOC" arr[ "1==6 2==3" ] = "REFUND" arr[ "1==4 2==5" ] = "INACTIVATION" arr[ "1==5 2==4" ] = "PENALTY" arr[ "1==5 2==1" ] = "SUBS. CREATE DIRECT DEBIT" arr[ "0==0 2==1" ] = "CREATION" # this needs special attention # $1 field strings arr[ "0==0 1==1" ] = "RESERVE" arr[ "0==0 1==2" ] = "COMMIT" arr[ "0==0 1==3" ] = "ROLLBACK" # $9 field, subfield 10 (by comma) strings - a key name "hack" arr[ "9==10 2==1" ] = "POSTPAID" arr[ "9==10 2==2" ] = "PREPAID" } # print output line here { print getString(0,1),getStringWithDefault(1,2),getString(2,3),$4,$5,$8,field9Strings() } function makeShortKey( field, value ) { gsub( value, "", " " ) return field "==" value } function makeLongKey( f1, v1, f2, v2 ) { return makeShortKey( f1, v1 ) " " makeShortKey( f2, v2 ) } function getStringWithDefault( a, b ) { sd = getString( a, b ) if( s == "" ) sd = getString( 0, b ) return sd } # take fields and their values to construct keys - 0 is special to 'standardize' keys function getString( field1, field2 ) { s = arr[ makeLongKey( field1, field1 == 0 ? 0 : $field1, field2, $field2 ) ] return (s == "") ? $field2 : s } function field9Strings() { split( $9, carr, "," ) sub( /\[/, "", carr[ 9 ] ); sub( /]/, "", carr[ 10 ]) s9 = arr[ "9==10 " makeShortKey( 2, carr[ 10 ] ) ] return carr[ 3 ] OFS ((s9 == "") ? carr[ 10 ] : s9) OFS carr[ 9 ] } </code></pre> <p>I've chosen to use the <code>arr</code> because I think it makes the strings more maintainable. I've tried to chose keys that would make it possible to read in those strings from an string file in another revision.</p> <p>The keys for field 9 parsing are "hard-coded" right now.</p> <p>For <code>arr[ "0==0 2==1" ]</code> I ended up adding a special <code>getStringWithDefault()</code> function. If "CREATION" depended on a value from column 1, the key could be updated and that function could be removed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload