I have a little program working and am trying to get the data read in from a file. After poking around a little I found the following method:
using Queryverse
open(“data.csv”) do f
# line_number
line = 0
# read till end of file
while ! eof(f)
# read a new / next line for every iteration
s = readline(f)
line += 1
push!(dataRead,"$s")
end
end
This works to create a Array that outputs:
Any[“0.30”, “0.34”]
However, for the rest of my program I need this to just be floats, so it should just read:
[0.30, 0.34]
I have tried variations on a number of methods proposed on this board, but can’t seem to get it to work. Ideally I guess it would be better if the data was just directly imported as a Float64, but I can’t figure out how to get it to do that.
You should really try to avoid arrays of Any if you can, they are very bad for performance. Can’t you make an array of strings instead? Or better yet, directly parse each line to float, and push them into a Float64 array?