I am trying to read a txt file with numpy and I have the following code
import numpy as np
def parsefile(filename):
return np.genfromtxt(filename,
delimiter = dly_delimiter,
usecols = dly_usecols,
dtype = dly_dtype,
skip_header = 4,
names = dly_names)
dly_delimiter = [7,5,9,13,10,13,9,13,10,13,10]
dly_usecols = [1,7]
dly_dtype = [np.int32, np.float64]
dly_names = ['node number', 'z_force']
force = parsefile('nodfor')
print(force)
And the following comes out
[(-1, nan) (-1, nan) (-1, nan) ..., (-1, nan) (-1, nan) (-1, nan)]
But what I am interested in are the number after 'nd#' and the number after 'zforce'.
[the format of the txt file is like this] and this is a snippet of the txt file (two lines):
nd# 39584 xforce= 0.0000E+00 yforce= 0.0000E+00 zforce=
0.0000E+00 energy= 0.0000E+00 setid = 1
nd# 39585 xforce= 0.0000E+00 yforce= 0.0000E+00 zforce=
0.0000E+00 energy= 0.0000E+00 setid = 1
Is this a known issue. How can I fix this?