I tried running this code with a slight modification but it does not seem to work as a DataFrames input. Using the file you provided as test input:
using JSON3: JSON3, StructType, Mutable
using DataFrames
mutable struct Node
nodeID::String
nodeUserID::String
parentID::String
nodeTime::String
informationID::String
Node() = new()
end
StructType(::Type{Node}) = Mutable()
lns = readlines("test.jsonl")
data = [JSON3.read(ln, Node) for ln in lns]
DataFrame(data)
julia> data = [JSON3.read(ln, Node) for ln in lns]
5001-element Array{Node,1}:
Node(#undef, #undef, #undef, #undef, #undef)
Node("phkmqmzpbv", "ufmgvgoure", "sgdibnesgi", "2019-03-05 13:10:51", "tyaekgxmsr")
Node("ugtkjodxer", "fhffxqbsoa", #undef, "2019-03-04 14:09:58", "bolwagblhx")
Node("alwwtfyunw", "qccqocykfm", "orjhhcvomh", "2019-03-05 01:37:58", "cagyezgppo")
⋮
Node("zuwjjgexbl", "opmkvyipxm", "sxavzrxldl", "2019-03-04 19:09:19", "tswwdiktno")
Node("ubaomyspwd", "jdoescksnv", #undef, "2019-03-05 15:18:43", "dbermznthm")
Node("optbrwcfli", "trrheeevlx", "ooxfkaspca", "2019-03-04 21:51:06", "vhdzurjxro")
Node("mlcxmfplei", "ojshhztncj", "ygotmuetnj", "2019-03-04 18:14:03", "rukafhqowm")
julia> DataFrame(data)
ERROR: UndefRefError: access to undefined reference
Any idea what I am doing wrong? (the modification is Status = new()
=> Node = new()
otherwise I get a Node is not callable
error)
EDIT: The problem are the #undef
values. I can create e.g. a Tables.columntable
out of rows 2 and 4
EDIT2: The following redefinition does work as a Tables.jl input as it avoids undef in construction
using StructTypes
mutable struct Node
nodeID::Union{String, Missing}
nodeUserID::Union{String, Missing}
parentID::Union{String, Missing}
nodeTime::Union{String, Missing}
informationID::Union{String, Missing}
Node() = new(missing, missing, missing, missing, missing)
end
StructTypes.StructType(::Type{Node}) = StructTypes.Mutable()