1 - I have a text file with approx. 12 millions of lines, each composed of 3 fields (column 1, 2, and 3)
2 - Most lines have a unique value in column 1. I don't want to modify these lines.
3 - Spread in the text file, I regularly have 2 consecutive lines with the same value in column 1. This roughly occurs 10,000 times in the entire text file. An example is shown hereunder:
column1 column2 column3
1
2
3
.
.
.
106 AAA X
106 BBB Y
.
.
.
2704 CCC X
2704 DDD Y
.
.
.
4 - What I would like to achieve?
Move the first line starting with 106 down by one position and move the second line starting with 106 up by one position. If I say that differently, I would like to swap the positions of 2 consecutive lines starting with the same value; hence Y would be before X in the final text file.
5 - Which resources I have?
5a: A text file with the 10,000 positions that are present twice (106 and 2704 in my example here).
5b: I also know X and Y that are always the same in lines starting with the same value in column 1.
5c: The energy and motivation to learn from your expertise.
It is the first time that I post a question and I hope I CLEARLY explained the challenge. Thanks in advance for your time and help. Deeply appreciated.