I would like to write a formula in which two of parameters are called from two separated files and the others are constant.The formula must be applied on each line of files and it goes for the next line. Finally, I want to write results to another file (out4.txt).
My files are like below:
I wrote a code like in the code block.
But the result in "out4.txt" is :
<generator object="" g.<locals="">.<genexpr> at 0x0000018B133B4EC8>
I dont know how to write results(calculated numbers) in my output file.
what is the problem? Also, am I right for choosing this method?
Thank you, in advance, for your answers.
What I have tried:
with open("position.xvg" , "r") as f1:
cn_xx = [float(x) for x in f1.read().splitlines()]
with open("velocity.xvg" , "r") as f2:
cn_vv = [float(x) for x in f2.read().splitlines()]
zipeed = zip(cn_xx , cn_vv) # from files
c0_xx = 1 #constant
c0_vv = 1 #constant
delta_t = 10 #constant
m = 18.01 #constant
for i in range(len(cn_xx)):
return ((cn_xx/cn_vv) + c0_vv + c0_xx + m + delta_t for (cn_xx , cn_vv) in zipeed)
result = g(c0_xx,cn_xx,cn_vv,c0_vv,m,delta_t)
with open ("out4.txt" , "w") as out_put:
print (result, file=out_put)