Read ASCII file in Pluto (convert a Vector{UInt} to a Vector{String} similar to readlines)

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");

we can then read the data using


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?

More information



Vector{UInt8} (alias for Array{UInt8, 1})


convert.(Char, name["data"])



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.

More playing around I got it! Eureka!

filelines = readlines(IOBuffer(name["data"]))

You could also use split(name["data"], '\n')

Hmm, tried it and split does not like a Vector{Uint8}. If I modify it to

split(string(Char.(name["data"])...), '\n')

to convert it to a Vector{Char} and from there to a string, then the split does work.

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.