script help 
Author Message
 script help

I am trying to create a script that will take a text file of pay
information and place it in to specific format.
The original file consists of 3 different type elements;

Pay code (unique, always one field in length with 7 numeric characters)
Pay description (may repeat in different pay codes. Varies from 2 to 7
fields, always leading with an asterisk)
Pay data (always 9 fields in length)

Any and all suggestion are welcome,

Thanks in advance

Eric

A source file may look like (format)

Pay code
Pay Description
Pay Data
Pay Description
Pay Data
Pay Description
Pay Data
Pay Data
Pay Data
Pay Data
Pay code
Pay Description
Pay Data
Pay Data
Pay Data

source example

00101
*10000 PAY
O1       04      2,512.80        1.0     2,512.80        0.00    0.00
0.00    2,512.80
*12300 RETIREMENT PAY
O6       24      0.00    0.0     0.00    0.00    0.00    0.00    0.00
*14000 HOUSING
O1       04      160.42          1.0     160.42          0.00    0.00
0.00    160.42
*15015 HOUSING - OPEN
O1       04      0.00    0.0     0.00    223.30          0.00    0.00
223.30
*15016 HOUSING W/O UTILITIES
O1       04      0.00    0.0     0.00    1,371.70        0.00    0.00
1,371.70
O1       00      0.00    0.0     0.00    32.40   0.00    0.00    32.40
00108
*30317 MORTAGE - OFF
O5       22      1,194.00        1.0     1,194.00        0.00    0.00
0.00    1,194.00
O5       18      2,290.50        2.0     1,145.25        0.00    0.00
0.00    2,290.50
O3       08      1,929.09        1.6     1,205.68        0.00    0.00
0.00    1,929.09
O2       06      218.63          0.2     43.72   0.00    0.00    0.00
218.63
*31100 PAY
O6       22      6,791.40        1.0     6,791.40        0.00    0.00
0.00    6,791.40
O5       22      11,929.20       2.0     5,964.60        0.00    0.00
0.00    11,929.20
O5       18      11,274.00       2.0     5,637.00        0.00    0.00
0.00    11,274.00
O4       20      332.44          0.1     33.24   0.00    0.00    0.00
332.44
O4       18      4,986.60        1.0     4,986.60        0.00    0.00
0.00    4,986.60
O4       14      4,781.70        1.0     4,781.70        0.00    0.00
0.00    4,781.70

The desired out come would look like (format

Pay code Pay Description Pay Data
Pay code Pay Description Pay Data
Pay code Pay Description Pay Data
Pay code Pay Description Pay Data
Pay code Pay Description Pay Data
Etc...

out come example

00101 *10000 PAY        O1       04      2,512.80        1.0
2,512.80        0.00    0.00    0.00    2,512.80
00101 *12300 RETIREMENT PAY     O6       24      0.00    0.0     0.00
0.00    0.00    0.00    0.00
00101 *14000 HOUSING    O1       04      160.42          1.0
160.42          0.00    0.00    0.00    160.42
00101 *15015 HOUSING - OPEN     O1       04      0.00    0.0     0.00
223.30          0.00    0.00    223.30
00101 *15016 HOUSING W/O UTILITIES      O1       04      0.00    0.0
0.00    1,371.70        0.00    0.00    1,371.70
00101 *15016 HOUSING W/O UTILITIES      O1       00      0.00    0.0
0.00    32.40   0.00    0.00    32.40
00108 *30317 MORTAGE - OFF      O5       22      1,194.00        1.0
1,194.00        0.00    0.00    0.00    1,194.00
00108 *30317 MORTAGE - OFF      O5       18      2,290.50        2.0
1,145.25        0.00    0.00    0.00    2,290.50
00108 *30317 MORTAGE - OFF      O3       08      1,929.09        1.6
1,205.68        0.00    0.00    0.00    1,929.09
00108 *30317 MORTAGE - OFF      O2       06      218.63          0.2
43.72   0.00    0.00    0.00    218.63
00108 *31100 PAY        O6       22      6,791.40        1.0
6,791.40        0.00    0.00    0.00    6,791.40
00108 *31100 PAY        O5       22      11,929.20       2.0
5,964.60        0.00    0.00    0.00    11,929.20
00108 *31100 PAY        O5       18      11,274.00       2.0
5,637.00        0.00    0.00    0.00    11,274.00
00108 *31100 PAY        O4       20      332.44          0.1     33.24
0.00    0.00    0.00    332.44
00108 *31100 PAY        O4       18      4,986.60        1.0
4,986.60        0.00    0.00    0.00    4,986.60
00108 *31100 PAY        O4       14      4,781.70        1.0
4,781.70        0.00    0.00    0.00    4,781.70



Fri, 02 Jan 2004 23:44:48 GMT  
 script help

I am trying to create a script that will take a text file of pay
information and place it in to specific format.
The original file consists of 3 different type elements;

Pay code (unique, always one field in length with 7 numeric characters)
Pay description (may repeat in different pay codes. Varies from 2 to 7
fields, always leading with an asterisk)
Pay data (always 9 fields in length)

Any and all suggestion are welcome,

Thanks in advance

#!/bin/awk -f
NF==1{paycode=$0;next}
/^\*/{paydesc=$0;next}
{print paycode,paydesc,$0}



Sat, 03 Jan 2004 21:54:54 GMT  
 script help
Thanks Bill

It works wonderfully

Eric

Quote:


> I am trying to create a script that will take a text file of pay
> information and place it in to specific format.
> The original file consists of 3 different type elements;

> Pay code (unique, always one field in length with 7 numeric characters)
> Pay description (may repeat in different pay codes. Varies from 2 to 7
> fields, always leading with an asterisk)
> Pay data (always 9 fields in length)

> Any and all suggestion are welcome,

> Thanks in advance

> #!/bin/awk -f
> NF==1{paycode=$0;next}
> /^\*/{paydesc=$0;next}
> {print paycode,paydesc,$0}



Mon, 05 Jan 2004 06:35:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Two file sort script Help...

2. Script help

3. Script Help with awk

4. Script Help

5. Newbie Scripting help

6. awk script help

7. Two file sort script Help...

8. dang this script...HELP!

9. TCP/IP logon script help needed

10. Guiding Viewpoint from Script: Help Please

11. Vrml &Script help !

12. Linux and Python scripts, help needed

 

 
Powered by phpBB® Forum Software