mardi 17 février 2015

Add every two consecutive lines in a column and divide it with the former and Print


I have a input file of almost 2000 lines. I have to do a calculation and print it in the third column.


Example of what I have to do with the Input File:



n ID1_1 n/(n+k)
k ID1_2


Input File:



10 ID1_1
20 ID1_2
1 ID3_1
9 ID3_2
15 ID2_1
300 ID2_2


Expected Output:



10 ID1_1 0.33
20 ID1_2
200 ID3_1 0.11
9 ID3_2
15 ID2_1 0.047
300 ID2_2


Do you have any easy way to solve it? Thanking you.



Aucun commentaire:

Enregistrer un commentaire