I have a case.py which reads CASE.dat
import math
import numpy as np
with open("CASE.dat", "r") as msg:
data = msg.readlines()
for i, line in enumerate(data[2:]):
if len(line.strip().split()) < 6:
break
row = list(map(float, line.strip().split()))
if round(row[4]) == 1:
val = 1
elif round(row[4]) == 4:
val = 2
row[4] = row[4] + val
if round(row[4]) == 6:
row[4] = 6 - row[4]
elif round(row[4]) == 2:
row[4] = np.abs(row[4] - 2)
data[i+2] = " ".join(map(str,row))
for row in data[2:]:
if len(row.strip().split()) < 6:
break
print (row.split()[0],row.split()[4])
It give me data like
1.0 0.06409900000000013
2.0 -0.033354000000000106
3.0 -0.008829999999999671
and so on I am looking for a modification in such a way that it prints the data like
1 0.0640
2 -0.0333
3 -0.0088