I'm trying to read in a text file and format it correctly in a numpy array.
The Input.txt file contains:
point_load, 3, -300
point_load, 6.5, 500
point_moment, 6.5, 3000
I want to produce this array:
point_load = [3, -300, 65, 500]
My code is:
a = []
for line in open("Input.txt"):
li=line.strip()
if li.startswith("point_load")
a.append(li.split(","))
#np.flatten(a)
My code prints:
[['point_load', ' 3', ' -300'], ['point_load', ' 6.5', ' 500']]
Any help would be appreciated. Thank you.