Hi,
Suppose I have a space delimited file like this:
Serial# 1970 1971 1972 1973 1974
193532 21 2 X X X
200201 20 30 X X 40
200201 X X 13 15 X
393666 66 3 X X 5
393666 77 X X X X
First, I want to check the serial#, if any two lines have the same serial#,(in this case line 2+3, and line 4+5 qualify), then merge these two lines by replacing X with the value of the other line.
Also, when there is a conflict, in this case line 4+5 have the first column as 66,77(rather than having X in either line or in both lines), then do not merge even though they have the same serial#, but flag both lines with FLAGGED on the CONFLICT_FLAG column.
The result would be:
Serial# 1970 1971 1972 1973 1974 CONFLICT_FLAG
193532 21 2 X X X
200201 20 30 13 15 40
393666 66 3 X X 5 FLAGGED
393666 77 X X X X FLAGGED
Is it possible to do this in either python or awk? Thank you.