I have a text file saved in the name 'test_file' that contain 6 rows and 7 columns as given below
0.00 5.8 2.0 5.0 6.0 8.0 0.0
10.00 5.8 2.0 1.0 1.0 1.2 9.6
10.00 9.3 2.2 2.0 1.4 2.5 9.6
30.00 9.3 2.2 1.2 1.5 1.9 1.4
30.00 9.3 2.2 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
I want to do some text manipulation in second and third column.
In the third column first two rows values should be same (2.0 and 2.0) and next three rows values are just the 0.2 increment of second row value(2.0+0.2=2.2,2.0+0.2=2.2,2.0+0.2=2.2).However, i don't want to change last row i want to keep it as it is.
After that in the second column, first two rows values should be just the multiplication of, first two rows of third column with 2.9.
similarly next three rows of second column are just the multiplication of next three rows of third column with 4.227
other columns values i don't want to change at all.
Now i want to change the first two rows value of third column sequentially, 2.1,2.2....2.5 followed by same increment and multiplication.
For example when i change first two rows values of third column from original 2.0 to 2.1 then the expected output should be
0.00 6.09 2.1 5.0 6.0 8.0 0.0
10.00 6.09 2.1 1.0 1.0 1.2 9.6
10.00 9.722 2.3 2.0 1.4 2.5 9.6
30.00 9.722 2.3 1.2 1.5 1.9 1.4
30.00 9.722 2.3 3.2 2.4 1.2 4.1
60.00 9.8 3.5 1.4 2.7 3.2 4.5
and i want to save the output file in different name such as file2.1.txt....file2.5.txt
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…