I am reading data into Pluto from an ASCII file. I note that when I use the PlutoUI command
@bind name PlutoUI.FilePicker([MIME("text/plain")])
that it returns both the file name and the data in some format. What I want is the data from the file. Let’s say we have a file such as
open("my_file.txt", "w") do io
write(io, "JuliaLang is a GitHub organization.\nIt has many members.\n");
end
we can then read the data using
readlines(name["name"])
which displays in Pluto as
["JuliaLang is a GitHub organization.", "It has many members."]
However this only works in the current working directory, as the file path is not tracked. Since there is also a variable name["data"], I am wondering if I can create a Vector of Strings equivalent to the readlines command from this information?
I think I can create a function to make this into a vector of Strings like readlines() does, but I also suspect there is a command within Julia that will do this. Will keep looking and appreciate your help.
You can directly do String(name["data"]) which is more efficient because it directly utilizes the memory and doesn’t need to construct intermediates. It also empties the original vector though.