I have a text file which contains rows of information in the form of both strings, integers and floats, separated by white space, e.g.
HIP893 23_10 7 0.028
4
HIP1074 43_20 20 0.0141 1
HIP1325 23_10 7 0.02388 5
...
I've imported this data using the following line:
data=np.genfromtxt('98_info.txt', dtype=(object, object, int,float,float))
However when I do this I get an output of
[(b'HIP893', b'23_10', 7, 0.028, 4)
(b'HIP1074', b'43_20', 20, 0.0141, 1)
(b'HIP1325', b'23_10', 7, 0.02388, 5)
... ]
Whereas I would like there to be no 'b' and instead:
[('HIP893', '23_10', 7, 0.028, 4.0)
('HIP1074', '43_20', 20, 0.0141, 1.0)
('HIP1325', '23_10', 7, 0.02388, 5.0)
... ]
I have tried NumPy's core.defchararray but that gave me the error 'string operation on non-string array', I guess because my data is a combination of both strings and numbers maybe?
Is there some way to either remove the character but keep the data in an array or perhaps another way to load in the information that will keep the strings in quotation marks and the numbers without them?
If there is a way to import it in that form as a 2d np array even better, but that is not an issue if not.
Thanks!