I am trying to read a CSV file that has a column of Arrays. While reading it via CSVFiles.jl
and CSV.jl
the column of arrays are loaded as String.
This is how that specific column values look like in the CSV File
I am trying to read a CSV file that has a column of Arrays. While reading it via CSVFiles.jl
and CSV.jl
the column of arrays are loaded as String.
This is how that specific column values look like in the CSV File
That looks like a perfect use case for jsonlines Initial version of my first package: A JSON Lines reader
At the moment the package assumes that the lines are json objects (“{…}”) rather than json arrays (“[…]”) but I can work on that
I think I found the solution.
Used the following code:
map(x->parse.(Int64,x),[split(chop(elements, head=1), ",") for elements in q_meta[:SubjectId] ])
where SubjectId
is the column name and q_meta
is the csv file loaded as a data frame.
Files with arrays similar to the first example on the JSONLines website can now be read using the readarrays(file)
function. I plan to eventually merge this into the readfile
function but I have to clean up the code first.
Check out:
https://github.com/danielw2904/JSONLines.jl/commit/7afa32f7fbc0921c489603c8290d00d61ffc475f