Hi. Just playing about with Daft for the first tim...
# general
a
Hi. Just playing about with Daft for the first time. I'm trying to load a JSON file containing an array of records using
daft.read_json("my-data.json").show()
. From what I'm seeing though it's expecting an object, not an array, and doesn't seem happy about multi-lines either. I've looked through the docs but not finding much on JSON. Am I doing something wrong or is this expected behaviour?
k
Hey Adam, Daft expects the JSON to be line delimited, essentially one json object per line of the file. It then translates that into one JSON object per row in the dataframe.
j
Yup! Doesn’t make much sense for us to be reading a single json object If so, you might want to consider loading it into memory first with just raw Python
json
module in stdlib!
a
Thanks for the quick response. Ok, that makes sense. So if I'm starting with a JSON file with an array of objects using multi line formatting, I should transform it into object-per-line first. Will keep playing. Thanks!
❤️ 1