I have data result from this code
import os
with open('c.txt', 'r', encoding='utf-8') as f1, open('c.txt', 'r', encoding='utf-8') as f2, open('r.txt', 'w', encoding='utf-8') as outfile:
for i, line in enumerate(f1):
xi, yi = (float(n) for n in line.split())
f2.seek(0)
for j, line in enumerate(f2):
if i < j:
xj, yj = (float(n) for n in line.split())
print( ((xi-xj)**2-(yi-yj)**2), file=outfile)
print(((xi)**2-(yi)**2), file=outfile)
this code should give me the calculations but need to print the position of x and y every time it is calculated to be like this
1 2 0.5
1 3 0.55
1 4 2.02
and so on. I tried to write the code but couldn't merge the concept I want. I think I need to write this code to get the position of the value and print it
for pos in range(len(f1)):
cor = t[pos]
f.write(str(pos) + ' ' + str(cor[0]) + ' ' + values + '\n')
but coluldn't merge it
sample of c.txt like
9.2 2.02
-2.3 1.5