heidik 0 Light Poster

Hello everyone.

Is it possible to read two lines of a file in one iteration based on some condition? The files has several blocks of data where each block contains two consecutive lines having ORDER ID in it. I want to store each of these IDs for each block of data in two different variables e-g

string ordID_1,ordID_2;

and then compare this pair of IDs

(ordID_1,ordID_2)

with the pair of IDs

(ordID_1,ordID_2)

in all the rest of the blocks. If the pair of IDs matches any of the pairs in the rest of the blocks then the two blocks would be called duplicates. Also there can be more than one duplicate for a block (not just one). Could anyone please help me with achieving this goal?

The file contains data like

0:1:ORDER ID:0001VVYF
0:2:ORDER ID:0001VW1S
... another line ...
... another line ...
... another line ...
... another line ...
... another line ...
0:0:2nd-ORD-TO-WASH-TIME-DIFF,500.881
then a similar block appears again in the file
1:1:ORDER ID:0001VVYF
1:2:ORDER ID:0001VW1S
... another line ...
... another line ...
... another line ...
... another line ...
... another line ...
0:0:2nd-ORD-TO-WASH-TIME-DIFF,501.991
... and so on ...

and this is the code I have so far.

while(getline(is,line))
{
	size_t pos = line.find("ORDER ID");
		
	if (pos != string::npos)
	{
		string ordID_1,ordID_2;						
						
		stringstream ss(line);
                         
                const int n_colons = 3;  // number of colons to skip
                         
                for (int i=0; i<n_colons; ++i)
                {
                 	getline(ss,line,':');
                }
                         
                getline(ss,line); // rest of line after the "n_colons" colons
		cout << "line = " << line << endl;
	}
}