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
Tag: json
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
FastAPI is very slow in returning a large amount of JSON data
I have a FastAPI GET endpoint that is returning a large amount of JSON data (~160,000 rows and 45 columns). Unsurprisingly, it is extremely slow to return the data using json.dumps(). I am first reading the data from a file using json.loads() and filtering it per the inputted parameters. Is there a faster way to return the data to the
Element is removed from whole dictonary instead of particular key in dynamic dictonary in python
I am creating a dynamic dictionary. I want to remove the element from a particular array but it is removed from the whole dictionary. In below code I want to remove vehicle id 11 from the time slot “01:01:00 to 01:30:00”. This code removes vehicle id 11 from the whole dictionary. Actual Output Expected output should be It is working
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
Tweepy search seems to loop till rate limit is met / not respect the count in the search
I trust all is well with you and yours / thanks for taking a moment to read this. I am trying to figure out why this section of code does not respect 2 things. the count limit, it is supposed to only pull that many tweets, and it does whatever it wants to do. the code seems to loop indefinitely,
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