'How to execute python module?
I want to execute following Python module named JD.py using results.py file and lines.txt. these files are given below:
JD.py
def line_info():
import fileinput
import os
n_1 = []
for line in fileinput.input(os.path.join(os.path.dirname(__file__),'lines.txt')):
s_n=0
n_n=0
C_1 = list(map(float,line.split( ))) # OR C_1 = [float(x) for x in line.strip().split()]
X=[]
Y=[]
Z=[]
n_1=[]
X.append(C_1[0])
Y.append(C_1[1])
Z.append(C_1[2])
s_n += 1
n_n+=1
n_1.append([s_n, n_n,C_1[0], C_1[1], C_1[2]])
return n_1
results.py
import JD as n_1
N= n_1.line_info()
print(N)
**
> lines.txt
**
0.2356 0.7568 0.4389
0.6356 0.8568 0.5389
0.9356 0.7568 0.6689
0.0356 0.8568 0.6389
0.8356 0.2568 0.7389
0.8756 0.5568 0.8389
but it gives first line of the .txt file only. how can I get the remaining lines of the .txt file as results.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
