Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with text

Status
Not open for further replies.
Aug 30, 2001
58
US
Good morning heres the issue. I have a text file with many records in it formatted like so

Code:
0000  [COLOR=red]0000272600111[/color]  MERCHANT                        01/31/06  SERVICE REP..               DATE OPENED 09/09/03                   
                                                                                                                                     
 CRD/CHG  DEBITS/ITEMS  CREDITS/ITEMS     DISC    PER ITEM   INTRCG        DISC    PER ITEM   INTRCG            MTD           YTD    
 30 1203       8914.93            .00          .00                .00          .00                 .00             .00           .00 
                   180              0      .00%         .00                              .00                       .00           .00 
 32 1203       2122.60            .00          .00                .00          .00                 .00             .00           .00 
                    43              0      .00%         .00                              .00                       .00           .00 
 40 1213        135.76            .00         3.34                .00          .13                3.42             .21-          .21-
                     3              0     2.46%         .00                              .05                       .05-          .05-
 40 1231        530.15            .00         9.12                .00          .49               10.51            1.88-         1.88-
                    44              0     1.72%         .00                              .66                       .66-          .66-
 40 1250       8819.50            .00       151.70                .00         8.16              154.82           11.28-        11.28-
                   190              0     1.72%         .00                             2.85                      2.85-         2.85-
 40 1288        140.44            .00         3.45                .00          .13                3.99             .67-          .67-
                     2              0     2.46%         .00                              .03                       .03-          .03-
 40 1289       2985.39            .00        73.44                .00         2.76               75.88            5.20-         5.20-
                    72              0     2.46%         .00                             1.08                      1.08-         1.08-
 40 1352       4551.59            .00        78.29                .00         4.21               95.68           21.60-        21.60-
                    92              0     2.02%         .00                             1.38                      1.38-         1.38-
  [COLOR=red]    SURCHARGE                              13.65        [/color] .00                                                   13.65         13.65 
 SUBTL        17162.83            .00       319.34                .00        15.88              344.30           40.84-        40.84-
                   403              0     1.86%         .00                             6.05                      6.05-         6.05-
 41 1223       2830.03            .00        69.62                .00         2.62               67.67             .67-          .67-
                    54              0     2.46%         .00                              .81                       .81-          .81-
 42 1213        425.93            .00        10.48                .00          .39               10.26             .17-          .17-
                    14              0     2.46%         .00                              .21                       .21-          .21-
 42 1231       1077.27            .00        18.53                .00         1.00               21.03            3.50-         3.50-
                    95              0     1.72%         .00                             1.43                      1.43-         1.43-
 42 1250      20094.86            .00       345.63                .00        18.59              288.14           38.90         38.90 
                   490              0     1.72%         .00                             7.35                      7.35-         7.35-
 SUBTL        21598.06            .00       374.64                .00        19.98              319.43           35.23         35.23 
                   599              0     1.73%         .00                             8.99                      8.99-         8.99-
 50 1203         90.15            .00         2.22                .00          .09                2.64             .51-          .51-
                     2              0     2.46%         .00                              .03                       .03-          .03-
 50 1223       8545.66            .00       146.99                .00         8.12              157.90           19.03-        19.03-
                   186              0     1.72%         .00                             2.79                      2.79-         2.79-
 50 1273        173.62            .00         3.66                .00          .16                3.78             .28-          .28-
                     4              0     2.11%         .00                              .06                       .06-          .06-
 50 1287        267.50            .00         6.58                .00          .25                6.45             .12-          .12-
                     3              0     2.46%         .00                              .05                       .05-          .05-
 50 1389        231.35            .00         3.98                .00          .22                4.67             .91-          .91-
                     9              0     1.87%         .00                              .14                       .14-          .14-
      [COLOR=red]SURCHARGE                                .35[/color]         .00                                                     .35           .35 
 SUBTL         9308.28            .00       163.43                .00         8.84              175.44           20.85-        20.85-
                   204              0     1.75%         .00                             3.07                      3.07-         3.07-
 51 1214         40.13            .00          .99                .00          .04                 .86             .09           .09 
                     1              0     2.47%         .00                              .02                       .02-          .02-
 51 1223       2391.18            .00        58.82                .00         2.27               56.20             .35           .35 
                    53              0     2.46%         .00                              .80                       .80-          .80-
0                               PAGE     1     FOR ASSOCIATE 001          OF PRINCIPAL 001                                           
1CORP: 027 EVO-MSI    REGN: 26 VISION         MONTH-END PROFITABILITY REPORT                 AS OF: 02/01/2006 MMBSR541 PAGE:  82,166
 PRIN: 001 VISION PAYMENT SOLUTIONS           ASSOC: 001 VPS SETUP                             RUN: 02/02/06   10:11:21 RCS :  MM541 
 CHN  MERCHANT NBR      *----------- NAME -----------* LST ACTIVE                                                                    
                                       *-------------INCOME-----------* *------------EXPENSE-----------*  *--------NET INCOME-------*
                                                                                                                                     
0SUBTL         2431.31            .00        59.81                .00         2.31               57.06             .44           .44 
                    54              0     2.45%         .00                              .82                       .82-          .82-
 52 1223       5830.72            .00       100.29                .00         5.54               74.29           20.46         20.46 
                    87              0     1.72%         .00                             1.31                      1.31-         1.31-
 52 1231        246.09            .00         4.23                .00          .23                4.78             .78-          .78-
                    21              0     1.72%         .00                              .32                       .32-          .32-
 52 1250       1697.62            .00        29.20                .00         1.61               26.98             .61           .61 
                    68              0     1.72%         .00                             1.02                      1.02-         1.02-
 52 1273         72.54            .00         1.53                .00          .07                1.51             .05-          .05-
                     2              0     2.11%         .00                              .03                       .03-          .03-
 SUBTL         7846.97            .00       135.25                .00         7.45              107.56           20.24         20.24 
                   178              0     1.72%         .00                             2.68                      2.68-         2.68-
 [COLOR=red]SURCHARGE TOTAL                             14.00       [/color]  .00                                                   14.00         14.00 
 MONETARY                                                                                                                            
 TOTAL        72215.01            .00      1136.09                .00        57.08             1071.46            7.55          7.55 
                  1715              0     1.57%         .00                            22.42                     22.42-        22.42-
                                                                                                                                     
 FLOAT CHARGES                                                                           .00                       .00           .00 
                                                                                                                                     
                                                                                                                                     
 CRD/CHG         OVER         UNDER           OVER          UNDER              OVER          UNDER             MTD           YTD     
 30 2433             179            0            17.90            .00             13.43            .00            4.47          4.47 
 32 2433              44            0             4.40            .00              3.30            .00            1.10          1.10 
 40 2433            1066            0           213.20            .00             79.95            .00          133.25        133.25 
 50 2433             439            0            87.80            .00             32.93            .00           54.87         54.87 
 AUTHORIZATION                                                                                                                       
 TOTAL              1728            0           323.30            .00            129.61            .00          193.69        193.69 
                                                                                                                                     
                                                                                                                                     
 CHARGE TYPE     ITEM         BATCH           ITEM          BATCH               ITEM          BATCH             MTD           YTD    
    3008            1715           32              .00            .00               .00            .80             .80-          .80-
                                                                                                                                     
 SCAN TOTAL         1715           32              .00            .00               .00            .80             .80-          .80-
                                                                                                                                     
                                                                                                                                     
 CHARGE TYPE        QUANTITY                                                                                    MTD           YTD    
    6112                    1                            5.00                              .49                    4.51          4.51 
                                                                                                                                     
 MISC TOTAL                 1                            5.00                              .49                    4.51          4.51 
                                                                                                                                     
                                                                                                                                     
0    MERCHANT[COLOR=red] 0000272600000111 [/color] TOTAL:                 1464.39                          1281.86                  182.53        182.53 
                                                                                                                                     
 ------------------------------------------------------------------------------------------------------------------------------------
The record begins with 00002726xxxxxx and ends with the line 00002726xxxxx. I need to take that 00002726xxxx number and use it as an identifier.

After that I need to pull out the number corresponding with SURCHARGE and match that up with 00002726xxxxxx. But NOT SURCHARGE TOTAL. Like so

000027260000111 13.65
000027260000111 0.35

Any thoughts on how I might accomplish this? I will be using a shell script or perl.
 
oops the end was cut off...

The record begins with 00002726xxxxxx and ends with the line 00002726xxxxx. I need to take that 00002726xxxx number and use it as an identifier.

After that I need to pull out the number corresponding with SURCHARGE and match that up with 00002726xxxxxx. But NOT SURCHARGE TOTAL. Like so

000027260000111 13.65
000027260000111 0.35

Any thoughts on how I might accomplish this? I will be using a shell script or perl.
 
A starting point:
awk '
/DATE OPENED/{id=$2}
$1=="SURCHARGE" && $2!="TOTAL"{print id" "$2}
' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
well it worked... but i have no clue how it worked lol

please help me understand! :)
 
done... how would i make it stop at

Code:
********** E N D O F R E P O R T F O R P R I N C I P A L 1 0 0 **********
 
How do I print all of that information for only the items between /DATE OPENED/ and /MERCHANT 00002726/ ?
 
here is what i ended up with

come to find out if i grab just the surcharge totals i am g2g

Code:
#!/bin/sh
awk '/DATE OPENED/,/MERCHANT 00002726/' jan.txt > jan1.txt
awk '/DATE OPENED/{id=$2} /SURCHARGE TOTAL/{print id" "$5}' jan1.txt > testem.txt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top