Parsing text file into a multidimensional array

Unless the order of words matters to you, I would do something like

function parse_wordinfo(io::IO)
    table = Dict{String,Vector{String}}()
    for line in eachline(io)
        parts = split(line, ' ')
        word = first(parts)
        syllables = parts[2:end]
        table[word] = syllables
    end
    table
end

I did not test this, and I am not sure I fully understand the spec, so fix/modify accordingly. If you do need the order, push!(container, word => syllables) could be a solution.

1 Like