text file

hey all
Guys can anyone plz tell me how can I delete the first and last line in an interval

s 167.204369958 _7_ MAC  --- 29867 tcp 630 [13a 8 7 800] ------- [7:2 8:1 32 8] [330 0] 0 1..
r 167.209410087 _8_ MAC  --- 29867 tcp 572 [13a 8 7 800] ------- [7:2 8:1 32 8] [330 0] 1 1..
s 167.212674795 _7_ MAC  --- 29868 tcp 630 [13a 8 7 800] ------- [7:2 8:1 32 8] [331 0] 0 1..
r 167.217714923 _8_ MAC  --- 29868 tcp 572 [13a 8 7 800] ------- [7:2 8:1 32 8] [331 0] 1 1..
s 169.998902881 _7_ MAC  --- 30344 tcp 630 [13a 8 7 800] ------- [7:3 9:0 32 8] [147 0] 0 1..
r 170.003942963 _8_ MAC  --- 30344 tcp 572 [13a 8 7 800] ------- [7:3 9:0 32 8] [147 0] 1 1..
s 170.162989092 _7_ MAC  --- 30466 tcp 630 [13a 8 7 800] ------- [7:2 8:1 32 8] [334 0] 0 1..
r 170.168029172 _8_ MAC  --- 30466 tcp 572 [13a 8 7 800] ------- [7:2 8:1 32 8] [334 0] 1 1..


Delete these two lines

s 169.998902881 _7_ MAC  --- 30344 tcp 630 [13a 8 7 800] ------- [7:3 9:0 32 8] [147 0] 0 1..
r 170.003942963 _8_ MAC  --- 30344 tcp 572 [13a 8 7 800] ------- [7:3 9:0 32 8] [147 0] 1 1..


All those lines contain characters. What makes these two special?

The simple method is to read a line at a time and write it to output file if it is not special.
Thank u 4 your reply .... well my program is suppose to count the number of occurrence of the s and the r lines within intervals and divide the r by s ... the problem takes place when this case happens the s line is at the end of the first interval and the r line is at the beginning of the second interval leading to incorrect calculations as the received lines will be greater than the send lines giving a % greater than 100. here's my output


time limit: 180.000000000
Received = 1.000000000     170.003942963    Send= 0.000000000  Packet Delivery Ratioinf    sequenceno1 =30344      sequenceno2 =30344.
Received = 2.000000000     170.168029172    Send= 1.000000000  Packet Delivery Ratio200.000000000    sequenceno1 =30466      sequenceno2 =30466.
Received = 3.000000000     170.186522463    Send= 2.000000000  Packet Delivery Ratio150.000000000    sequenceno1 =30467      sequenceno2 =30467.


and here's my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 #include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>

    using namespace std;

int main()
{
    ofstream fout("TPDR[3-4-30].tr");
    ifstream fin("TTEST.tr");// if u use this as ur input file u will always get ur num as 6 because the range stops at 50 therefore u will get the throughputs calculated as 0z 
    ofstream fOut("TPDR30(3-4).tr");
    ofstream MYFILE("TPDR(3-4).tr");
    
    if (!fin)
    {
        cout << "input file not open" << endl;
        return 1;
    }

    fout << fixed << setprecision(9);
    fOut << fixed << setprecision(9);
    cout << fixed << setprecision(9);
    MYFILE << fixed << setprecision(9);

    double timelimit = 0.0;    // ending time of first block of data
    double timeincr  = 10.0;   // duration of each block of data

    string s1, s2, s3, sequenceno1,sequenceno2, s4, s5; // dummy variables to hold unwanted data 
    string line,oldline;
    
    char   type;   
    double time;   
    int    bytes;  
    int num = 0;
    istringstream ss;
    double received[21] = {0.0}; 
    double send[21] = {0.0}; 
    int drop[21] = {0}; 
    double Re[21]= {0.0};
    double Se[21] = {0.0};
    double De[21] = {0.0};
     int R = 0;
     int S = 0;
    double PDR =0.0;
    double PDRR[21] = {0.0};
    int Range; 
   
     
    //------- Priming read. Get first line.
    getline(fin, line);
    ss.str(line);
    ss >> type >> time;

    while (fin)
    {
        while (ss && time <= timelimit)
        {
			 
            //------------- process the line here ------------------
                 // ss >> s1 >> s2  >> s3 >> s4 >> s5 ;
                   
                             
                                
         if (type == 's') {
									  
		          ss >> s1 >> s2 >> s3 >> sequenceno1 >> s4 >> s5;
					  oldline = line;
					  send[num]++; 
					  S = send[num]; 
					  Se[num] = S; 
				  }
					  
					                  
               if (type =='r') {
					
					  ss >> s1 >> s2 >> s3 >> sequenceno2 >> s4 >> s5;
				  if ((time < timelimit)&&(sequenceno1 == sequenceno2)) {
					  cout << sequenceno1 << "   " << sequenceno2 << "    " << time << "    " << timelimit << ".\n";
				     received[num]++;
					 R = received[num];
					 Re[num] = R;
					 PDR = Re[num]/ Se[num];
					 PDRR[num] = PDR*100;
	
	fout << "Received = " << Re[num] <<"     " << time <<"    " << "Send= " << Se[num] << "  " << "Packet Delivery Ratio" << PDRR[num]  << "    "<< "sequenceno1 =" << sequenceno1 << "      "<< "sequenceno2 ="  << sequenceno2 << ".\n"; 
		
		
                }
        
                }
         
            //------------- end of process, now read the next line -----

            if (getline(fin, line))
            {
                ss.clear();             // clear all flags
                ss.str(line);
                ss >> type >> time;
            }
            else
            {
                ss.clear(ios::failbit); // set the fail flag
         
            }
            
        }
        
        

        timelimit += timeincr; // increment limit to next value
        cout << timelimit << ".\n\n";
        num++; 
        fout << "\n------------------\n";
        fout << "time limit: " << timelimit << endl;
        cout << "num = " << num << ".\n";
    } 
    
   // ..... Writting the Range and PDR within each Range in a separate File .....
   
for (Range = 10,num =1; Range <= 200, num <=20; Range+=10, num++) {
	fOut << Range << "     " << PDRR[num] << ".\n";
 } 
 
 double average = 0.0;
 double TPDR = 0.0;
 
 for (num = 1; num <=20 ; num++) {   // For loop to compute the Total PDR within each Range 
	 TPDR += PDRR[num]; 
	// cout << "TPDR" << TPDR << "%" << ".\n"; 
 }
 
 average = TPDR /(num-1);
 cout << "average = " << average << "%" <<  ".\n";// Compute Average PDR 
 
    cout << "Done" << endl;
    return 0;
}


Any ideas how to delete these lines in such case .. ps my trace file is really big that was just a snap shot

thank u loadz
@keskiverto can u plz help me out :( cant figure out how to delete these lines
Last edited on
I don't even know what is an "interval".
sry because I did not make it clear enough ... the interval is the range of time in the above example the first interval is from (160 - 170) and the second interval is from (170-180)... these are the times where I want to delete my lines
 169.998902881 
and
 170.003942963   
.
thanx in advance
Could you read two lines (both 's' and 'r') at a time, test that both are in interval, and only then compute something to show?
Topic archived. No new replies allowed.