I tried to read the contents of a 3x3 matrix stored in a text file having the following values.
−30 10 20
10 40 −50
20 −50 −10
I used numpy.genfromtxt
as follows but when it gave nan
in place of negative data values.
data = np.genfromtxt('file.txt',delimiter=' ')
print(data)
print(type(data[0][0]))
But the datatype of the negative value still shows float64
:
I also tried reading the values as a list and then converting to numpy array but that also didn't work.
Is there any other way I can read negative values as a numpy array from a file input?