Read the contents of a json file into a json object from a managed folder in dataiku
ssuhas76
Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31 ✭
I need to read contents of a jsonfile stored in a dataiku managed folder. Need the code for doing the same with dataikuapi package.
TypeError: the JSON object must be str, bytes or bytearray, not 'HTTPResponse'
import dataikuapi client = dataikuapi.DSSClient(host, apiKey) client._session.verify = False project = client.get_project("xxxxxxxxxxxxx") managedfolder = project.get_managed_folder("xxxxxxxxxxxxxxxxx") import json with managedfolder.get_file('xxxxxx.json') as fd: f = json.loads(fd.raw)
Answers
-
Hi @ssuhas76
,Because get_file() returns a requests Response, you can use Response.json() to read it:
with managedfolder.get_file('xxxxxx.json') as fd: f = fd.json()