I have a .dat file that looks like the following.
[1. 0.99999999 0.99999975 0.9999908 0.99986024 0.99899004
0.99591797 0.98880885 0.98462882 0.97393692 0.9566383]
I want to import it into an one dimensional array, [1,0.99999999,....,0.9566383].
I tried the following from this question.
with open('data.dat', 'r') as file:
data = file.read().replace('\n', '')
print(data)
I cannot convert the string data
into float, because all the digits, spaces and decimal points are going into the string. How do I ensure that the numbers like 0.99999975
are clubbed together (so that 0,.,9,9,...5 are not different entries), and the spaces are not counted as entries?