I hope someone can take some time out of their busy schedules to point me in the right direction as to how I should tackle this project; my immature programming head is just not grasping it at present, maybe I am over thinking it!

I basically want to construct a condition merge routine for a text readable file. One field contains a date to which I would like to assign a “quality” factor, another field containing Place detail I would use the number of comma delimiters as an indication of quality, more being more components and therefore more detailed. An example portion of the original file structure is below, this is a gedcom file (genealogy information)

Code:
0 @I1@ INDI ‘ start of information for individual#1
..
1 BIRT
2 DATE 1868 ‘ third highest quality score date
2 PLAC New York, America
..
1 BIRT 
2 DATE Mar 1868 ‘ second highest quality score date
1 BIRT
2 DATE 18 Mar 1868 ‘ highest quality score date
2 PLAC America
..
1 BIRT
2 DATE abt 1868 ‘ fourth highest quality score date
2 PLAC Sullivan County, NY, United States
..
0 @I2@ INDI ‘ start of information for individual#2
Constants are :-
“0 @I” starts each new person’s information block.
“1” starts each new event within the “0 @I” tags, in this case “1 BIRT” (birth)

The number of lines appearing between the “0 @I” tags and the “1 “ tags are totally variable. The “2 DATE” and “2 PLAC” may or may not appear.

Code:
1 BIRT
2 DATE 18 Mar 1868 ‘most accurate date and same year as others
2 PLAC Sullivan County, NY, United States
What I would like to work towards in this case is to reconstruct the information to one Birth Event with the most accurate information like the example above and discard the additional lesser quality information. Unfortunately at the moment I don’t have the experience to jump towards the right solution.

My thoughts were to read between the “0 @I” tags into fileINPUT array, reconstruct the information in fileOUTPUT array and write back to output file and also write changed information to a log file for auditing.

This is maybe far too ambitious for me at my stage of learning but no pain no gain, I believe once I get some experienced direction on how I should be tackling this problem and maybe a short example then I will start to achieve some real results.

In hope of your indulgence and a bit of patience from a family historian. (and newby programmer)