# M2SPREAD.AWK V2.3 # # This script transforms a punch (of a full matrix) generated by module 3.14 # into a table that can be imported into a spreadsheet program. # # Usage: gawk -f M2SPREAD.AWK nz= [format=] [sep=] [list=] 'infile' [> outfile] # example: gawk -f m2spread.awk nz=3 format=%5.4f sep=+ batchout > outfile # Input file contains data for 3 zones and the output separator is # specified as ",". # # Description of the parameters: # nz : maximum number of zones (or group number) used in the batchout. # This parameter must be defined! # Example: nz=5 # format : changes the number output format. This parameter is optional. # default: %5.4f (float of 5 digits with 4 decimals). # Example: format=%6.0f or format='%6.0f' (depending on system) # sep : changes the field separator. default: ",". This parameter is # optional. # Example: sep=; or sep=';' (depending of system) # infile : file name of the punch generated in module 3.14 of EMME/2. # outfile: file name for saving results # list : default 0. # When using the default list format (list=0), the result (outfile) # should look like this: # 1.2346,12.346,123.46 # 1234.6,12346,123456 # 0.0000,0.0000,1234567 # When using the alternate list format (list=1), the result # (outfile) should look like this: # 1,1,1.2346 # 1,2,12.346 # 1,3,123.46 # 2,1,1234.6 # 2,2,12346 # 2,3,123456 # 3,3,1234567 # # Data input: mfxx (full matrix) batchout from EMME/2 module 3.14. Two formats # can be used as the input file: a zone to zone punch (see example # 1) or a punch using a group ensemble (see example 2). The input # file must contain only one full matrix punch. # #=EXAMPLE 1: zone to zone======================================================= # c EMME/2 Module: 3.14(v7.01) Date: 94-06-09 11:31 User: E001/INRODEMO.2000 # c Project: EMME/2 STANDARD DEMONSTRATION AND TEST DATA BANK # t matrices # a matrix=mf01 test 0 Test matrix # 1 1: 1.23456 2: 12.3456 3: 123.456 # 2 1: 1234.56 2: 12345.6 3: 123456 # 3 3: 1234567 #=EXAMPLE 2: punch using group definition======================================= # c EMME/2 Module: 3.14(v7.01) Date: 94-06-09 11:32 User: E001/INRODEMO.2000 # c Project: EMME/2 STANDARD DEMONSTRATION AND TEST DATA BANK # t matrices # a matrix=mf01 test 0 Test matrix # ga01 ga01: 1.23456 ga02: 12.3456 ga03: 123.456 # ga02 ga01: 1234.56 ga02: 12345.6 ga03: 123456 # ga03 ga03: 1234567 # # # The file is processed line by line and the following rules are applied first: # - all lines beginning by "a", "c" and "t" are skipped # - all gX (where X is a letter a to z) and trailing zeros (0) after # gX will be removed (ga01 will be changed to 1) # - all ":" will be replaced by a blank (space). # # As an example, the line: # # ga01 ga01: 1.23456 ga02: 12.3456 ga03: 123.456 # # will be changed to: # # 1 1 1.23456 2 12.3456 3 123.456 # BEGIN { min=1 if (format=="") format="%5.4f" if (sep=="") sep="," if (list=="") list=0 ORIG=1 } NR==1 { if (!nz) error1(); fx = sprintf("%s%%s",format) } $1~/^a/ { NUL=$4 for(i = min;i < nz;i++){ VECT[i]=NUL } VECT[nz]=NUL } $0 ~/g[a-z]00/ {min=0} $0 !~ /^[cta]/ { clean_line() if (list==0) { if (NF>2) { if ($1==0){ for(i=2;i2) { for(i=2;i