mardi 28 septembre 2021

replacing values of a column with certain condition

i have a text file that contain four columns of data,I want to modify only 4th column with some conditions which is little bit tricky,

condition : If we see the 4th column, that contain negative and positive values.I just want to keep the negative values of 4th column if it falls within the range -1.249582196275393240e-02 and -2.100552742679913983e-02 and similarly i want to keep the positive values of the 4th column if it falls within the range 1.381056887718538353e-04 and 2.346095085764924595e-04. However remaining negative values of the 4th column should be replaced randomly and that random number should fall in the range -1.145493471994996071e-03 and -1.8445493471994996071e-03 and in the similar way the remaining positive values should fall randomly within the range 1.531056887718538353e-06 and 1.956056887718538353e-06.

0.00000000 2.99699998 -2.84957702E-09 -5.307858809828758240e-04
0.100000381 2.99699998 -4.68360684E-09 -6.632010918110609055e-04
0.200000763 2.99699998 -5.35559996E-09 -6.618221911291281021e-04
0.300001144 2.99699998 1.45702295E-09 -6.119244499132037163e-04
0.399999619 2.99699998 5.45327616E-10 -9.009421531421442375e-05
0.500000000 2.99699998 -1.14950405E-09 1.381056887718538353e-04
0.600000381 2.99699998 -1.66670497E-10 2.346095085764924595e-04
0.700000763 2.99699998 -9.37441375E-11 2.136244050537546566e-04
0.800001144 2.99699998 -1.36117896E-12 -7.592248342310388601e-06
0.899999619 2.99699998 -5.71992106E-13 -3.888342762365937233e-04
1.00000000 2.99699998 -6.03400088E-13 -3.404438806076844353e-04
1.10000038 2.99699998 -1.03240001E-13 -1.001964362027744396e-05
1.20000076 2.99699998 -0.00000000 7.743958073357740677e-04
1.30000114 2.99699998 -0.00000000 8.257767185568809509e-04
1.39999962 2.99699998 -0.00000000 3.288088676830133028e-05
1.50000000 2.99699998 -0.00000000 -1.937364577315747738e-04
1.60000038 2.99699998 -0.00000000 6.337644299492239952e-01
1.70000076 2.99699998 -0.00000000 7.002819329500198364e-01
1.80000114 2.99699998 -0.00000000 7.997010834515094757e-01
1.89999962 2.99699998 -0.00000000 3.407316592832406181e-01
2.00000000 2.99699998 -0.00000000 -1.045938600630809818e-04
2.10000038 2.99699998 -0.00000000 -4.584837394456068855e-04
2.20000076 2.99699998 -0.00000000 -4.834951056788365227e-04
2.30000114 2.99699998 -0.00000000 1.355664474734415701e-04
2.39999962 2.99699998 -0.00000000 8.168490603566169739e-04
2.50000000 2.99699998 -0.00000000 3.781475049133102280e-04
2.60000038 2.99699998 -0.00000000 -1.249582196275393240e-02
2.70000076 2.99699998 -0.00000000 -2.296202816069126129e-02
2.80000114 2.99699998 -0.00000000 -2.527230263998111234e-02
2.89999962 2.99699998 -0.00000000 -2.100552742679913983e-02
3.00000000 2.99699998 -0.00000000 -1.145493471994996071e-03
3.10000038 2.99699998 -0.00000000 -8.956699942549070084e-04
3.20000076 2.99699998 -0.00000000 -2.074862675120433316e-03
3.30000114 2.99699998 -0.00000000 -3.787500162919362531e-03
3.39999962 2.99699998 -0.00000000 -5.514865741133689880e-03
3.50000000 2.99699998 -0.00000000 -5.781509603063265772e-03
3.60000038 2.99699998 1.23875296E-07 -3.731979367633660779e-03
3.70000076 2.99699998 8.67075073E-07 -7.905315142124891281e-04

I tried with Replacing a string with a random number using awk, but couldnot do it.I hope experts may help me overcoming this problem.Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire