Skip to content
Advertisement

Tag: json

How do I get a specific element from a json string?

I have a JSON string (not in a file): [{‘x’: 403.5, ‘y’: 53.0, ‘width’: 117, ‘height’: 106, ‘class’: ‘fruitflies’, ‘confidence’: 0.626}, {‘x’: 446.0, ‘y’: 189.0, ‘width’: 124, ‘height’: 130, ‘class’: ‘fruitflies’, ‘confidence’: 0.528}], now as you can see, the entire string is in a list. Inside the list is the dictionary. There are 2 dictionaries in the list and I

Python: when trying to extract certain keys, how can I avoid a KeyError when in some dict elements, the key value is missing from APi json?

I can successfully extract every column using Python, except the one I need most (order_id) from an API generated json that lists field reps interactions with clients. Not all interactions result in orders; there are multiple types of interactions. I know I will need to add the flag to show ‘None’ and then in my for loop and an if-statement

Python read txt file and save it as json with keys

I have a txt file that presents some data as follow: The file is all structured in the same way, but I wanted to convert this file to a JSON format. Based on my experience, I decided to go first with a split to have a list to play with: This outputs the text as follow: which is perfect. Here

How to concatanate 2 dictionaries in 2 json files

Iam trying to append a dictionary in one json file to a dictionary in another json file. here are json file r1 json file r2 The result Iam looking for is Expected result My code is not returning the expected results Answer As the ‘Adrian shum’ said your json having the lists. in that case you can use nested for

Extracting JSON from HTML with BeautifulSoup

I’ve now tried everything for the past few hours but I can’t extract a specific thing from the HTML below. I want to grab the “sessionCartId” but I can’t figure out how…. Thats what i tried so far : ^^ This gives me the correct script tag but i cant transform it into a json nor get the sessioncarId Answer

Identifying empty list in JSON data in Python

I have a json data set I’m trying to insert into a database. To do so, I need placeholders “” for non-existent data. In the example below, if there’s no email address, I need the insert statement to be (….,”boo”,….) instead of (….,”me@mail.com”,….). I have tried checking for list length, using not, email == [], etc. Every way I know

Pandas won’t create CSV file?

just trying to save websockets to CSV’s. But it just doesnt make the file. Nothing in the directory. Tried running VScvode as admin, moving folder out of C: drive to documents .. nothing. no csv file, and no error. and no information on the internet about this either. So i kept stripping down the code to the most basic, and

Advertisement