I am using Julia 1.4 and CSV 0.62. I have a CSV file that has a column with some JSON in it (e.g. {"type":"Point","coordinates":[-3.73610686,58.3917902]}
)`. When I look at the data type I am told it is of type String. If I pull out one row’s value like this:
s = mydf[:geom][1]
I get an escaped string of type String that I can do normal string orperations on, like parse it into JSON using JSON.parse(). However, if I try to do any operation on the data in the dataframe like this (for instance):
mydf[:x] = JSON.parse(mydf[:geom])["coordinates"][1] #extract the first coordinate and store in a column named :x
then I get the following error:
ERROR: MethodError: no method matching parse(::WeakRefStrings.StringArray{String,1})
I get this same error if I try to replace the double quotes with anything. I also get the error if I manually strip out all the JSON parts of the string in Excel and leave only tuple. In other forums I see people saying to set the keyword argument weakrefstrings=false
. However, that is no longer a valid keyword argument so I can’t do that.
Can anybody suggest how I can handle this? Can I coerce the data into being a proper string perhaps?