How to read Panda's DataFrames from json file?

Ok, this basically follows what @TheCedarPrince outlined above:

using JSON3
using DataFrames

json_string = read("00_stats.json");
jsobj =  JSON3.read(json_string);

rows = DataFrame[];

for sym in keys(jsobj)
    # sym = :Var # For example.
    row = DataFrame([k => jsobj[sym][k] for k in keys(jsobj[sym])])
    insertcols!(row, 1, :KeyID => String(sym))
    push!(rows, row)
end

df = reduce(vcat,rows)

(The KeyIDs seem unintelligible to me but trust you can figure it out!)

2 Likes