Skip to content

Tag: json

How to read dictionaries in list of dictionaries in python

I am trying to read some JSON for a leaderboard for my discord bot, formatted like this: I can read the first part fine, but reading this list here is giving me some problems: How can I read the values of each of the dictionaries in the list? For example, say I want to get the dictionary with the key

Python: Safe dictionary access with lists?

Is there an exception free way to access values from a dictionary containing lists. For example, if I have: How do I access the path data[‘object_1’][‘object_2’][‘list’][0][‘property’] safely(i.e. return some default value if not possible to access without throw…

Convert JSON Dict to Pandas Dataframe

I have what appears to be a very simple JSON dict I need to convert into a Pandas dataframe. The dict is being pulled in for me as a string which I have little control over. I have tried the usual methods such as pd.read_json() and json_normalize() etc but can’t seem to get it anywhere close. Has anyone…

Finding the headers for values in Json files

Hi I’ve got json data that looks something like this: I’m looking to convert this into lists that look something like this: So far I’ve been able to get all the names that I want using objectpath. But I’ve been unable to get the appropriate headers for each name as it appears to be nes…

Labeling sentences from different nested dictionaries

I created a function to extract sentences from a specific key in a nested file. Now I would like to include in this function a label each time it comes to a new dictionary. Each time the the value HEADER appears marks the begining of a NEW story. So I would like to label the sentences that belong to the