Reconciliation

Guys, I am trying to do some reconciliation for text files. Here is an example of the data output:

19970929,162.5800,170.3200,157.4200,169.8100,31427893,125.0600
19970930,171.8700,172.9000,170.8400,172.9000,901641,127.3400
19971001,172.9000,177.5500,172.3900,177.0300,1101598,130.3900

What I would like to do is to reconcile in the following:
- if column A dates is more than 5 days a part - write a message
- if column B is greater than 10% away from each other - write a message
- if column C < D - write a message

I have no idea how to start this project. Please help me. Any suggestion on how to start or go about it will be appreciate it. Would like to thanks ahead of time. Thanks.
I would have a structure containing 7 elements representing the data. I would then calculate the new outputs, compare them with the old outputs and then copy the new outputs to the old outputs like so:
1
2
3
4
5
if ( abs(message_prev.colA - message.colA)>5) cout...
if ( abs(message_prev.colB - message.colB)/message_prev.colB >.1) cout...
if ( message.colC < message.colD) cout..

message_prev = message;
Last edited on
Stewbond,

I got each column to represent in their own array. But I am not sure how to set up "message_prev" Can you look over my codes and let me know if i am on a right track? Thanks.

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
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdlib.h>

using namespace std;

int main () 
{
  ifstream indata("Test.txt");

	while (!indata.eof())		// keep reading until end-of-file
	{  
	int test_array[7];
  
	int colA;			// variable for input value
	int colB;			// variable for input value
	int colC;			// variable for input value
	int colD;			// variable for input value
	int colE;			// variable for input value
	int colF;			// variable for input value
	int colG;			// variable for input value

  indata >> colA >> colB >> colC >> colD >> colE >> colF >> colG;
	
	test_array[0] = colA;
	test_array[1] = colB;
	test_array[2] = colC;
	test_array[3] = colD;
	test_array[4] = colE;
	test_array[5] = colF;
	test_array[6] = colG;

	int previous_array[7];
		int pcolA;
		int pcolB;
		int pcolC;
		int pcolD;
		int pcolE;
		int pcolF;
		int pcolG;

		previous_array[0] = pcolA;
		previous_array[1] = pcolB;
		previous_array[2] = pcolC;
		previous_array[3] = pcolD;
		previous_array[4] = pcolE;
		previous_array[5] = pcolF;
		previous_array[6] = pcolG;


		cout << pcolA << pcolB << pcolC << pcolD << pcolE << pcolF << pcolG << endl;

		
		if( abs(colA - pcolA) > 5)
			cout << "Gap in days" << endl;
		if( abs(colB - pcolB)/pcolB > .1)
			cout << "More than 10% change" << endl;
		if(colD > colC)
			cout << "High is lower than low" << endl;
	}
	indata.close();
  return 0;
}

Last edited on
If you are using pcolA anyways, then you don't need previous array; It appears you haven't learned structures yet so try this:

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
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdlib.h>

using namespace std;

int main () 
{
	ifstream indata("Test.txt");
	int pcolA=0, pcolB=0; //Stored variables for comparison (declare outside of while loop to avoid being re-defined every time).

	while (!indata.eof())		// keep reading until end-of-file
	{  
  
		int colA,  colB,  colC,  colD,  colE,  colF,  colG;	// variables for input value

		//Get data
		indata >> colA >> colB >> colC >> colD >> colE >> colF >> colG;

		//Do your comparisons
		if( abs(colA - pcolA) > 5)
			cout << "Gap in days" << endl;
		if( abs(colB - pcolB)/pcolB > .1)
			cout << "More than 10% change" << endl;
		if(colD > colC)
			cout << "High is lower than low" << endl;

		//Set your references for next time
		pcolA = colA; 
		pcolB = colB;
	}
	indata.close();
  return 0;
}
Last edited on
Oh wow, that condensed the code by a mile. When I start without debugging, a pop up comes "Has stopped working. a problem caused the program to stop working correctly." There was no error in the output.
Topic archived. No new replies allowed.