json

JSON From HTTP Print Value With Python

JSON From HTTP Print Value With Python Question: I’m grabbing JSON from an http link. I can print the entire json string, and I can print all of the key values. What I’m trying to do is to get only certain values based on an ID. Json output: { "common_list": [ { "id": "0x0B", "val": …

Total answers: 1

How, in Python 3, can I have a client open a socket to a server, send 1 line of JSON-encoded data, read 1 line JSON-encoded data back, and continue?

How, in Python 3, can I have a client open a socket to a server, send 1 line of JSON-encoded data, read 1 line JSON-encoded data back, and continue? Question: I have the following code for a server listening on a port: def handle_oracle_query(self, sock, address): sockIn = sock.makefile(‘rb’) sockOut = sock.makefile(‘wb’) line = sockIn.readline() …

Total answers: 2

load jsonl File with OpenAI API request results to pandas data.frame

load jsonl File with OpenAI API request results to pandas data.frame Question: I have a large data set containing around 500k observation. It has a string variable that I want to create an embedding for. I used the OpenAI API to create the embedding and because of the large number of observations I used their …

Total answers: 1

How to write to dictionary using user input and loop and parsing by space?

How to write to dictionary using user input and loop and parsing by space? Question: I am trying to create a dictionary that I can serialize into a json file. This is my first time trying this so I am very confused. I want user input for a patient’s first name, last name, age, and …

Total answers: 3

how to convert a JSON file to a desired dataframe with Python

how to convert a JSON file to a desired dataframe with Python Question: I have a Json file in a local folder, here is the .json file’s content: { "id": "TD3$-FFA", "shortCode": "TD3$-FFA", "dataSet": { "id": "TD3C", "shortCode": "TD3C", "shortDescription": "Dirty Middle East Gulf to China", "displayGroup": "BDTI", "datumUnit": "Worldscale", "datumPrecision": 2, "data": [ { …

Total answers: 1

How can I sort a JSON array by a key inside of it?

How can I sort a JSON array by a key inside of it? Question: I have an unknown number of items and item categories in a json array like so: [ { "x_name": "Some Name", "x_desc": "Some Description", "id": 1, "category": "Email" }, { "x_name": "Another name here", "x_desc": "Another description", "id": 2, "category": "Email" …

Total answers: 1

Removing Specific Lines in Json File

Removing Specific Lines in Json File Question: I am trying to clean the json file down below. I want to remove all the dict key value pairs for which the key is "Company" in the "Stores" list. { "Company": "Apple", "Stores": [ {"Company" : "Apple", "Location" : "-", "Sales": "-", "Total_Employees": "-" }, {"Company" : …

Total answers: 2

How do I add a space between the Double Quotes and Colon in the key values of the dictionary?

How do I add a space between the Double Quotes and Colon in the key values of the dictionary? Question: The following is my code: import json def value_list(sentence): word_list = sentence.split(" ") total_number_of_words_in_the_sentence = len(word_list) value_list = [] for i in range(0, total_number_of_words_in_the_sentence): count1 = word_list.count(word_list[i]) value_list.append(count1) return value_list def wordlist1(sentence): import json word_list …

Total answers: 1

python Object of type 'Attribute' is not JSON serializable

python Object of type 'Attribute' is not JSON serializable Question: I am beginner in python, I am trying to write a python script to convert the ldap query result to json object. After I get the datadump to the variable c, I attempt to format the string that I will use to convert to json …

Total answers: 1