All Questions
Tagged with python-3.x json
4,378
questions
0votes
3answers
33views
How would you convert the following dictionary to a specific JSON structure?
I'm by far not a Python3 hero, but focussed on learning some new skills with it, thus any help would be appreciated. Working on a personal project that I want to throw on GitHub later on, I run into ...
0votes
0answers
8views
Dash Plotly error TypeError: Object of type DataFrame is not JSON serializable
Hello I am working with Dash for making dashboard.
Below is my code.
I tried to fix the error but not able to fix, Can anyone look into this?
on chrome i am getting. Error loading layout
I am getting ...
-1votes
0answers
7views
How do I get the delete button to work using Python3 in a flask framework?
I'm currently enrolled in a full stack development course, I cant figure out why my delete button doesn't work. Im learning javascript, I was able to create checkboxes for created list and was able to ...
-3votes
0answers
16views
Python Get Average of Multiple Nested Dictionaries [closed]
I have a list of dictionaries. Each dictionary by itself can have nested levels, but the keys will always be the same. I'm trying to find the best way to get the mean of these values.
Example List of ...
0votes
1answer
12views
Python 3 subprocess, how to read json file
I am trying to make a script that needs to be executed locally and connect to a remote server via SSH. So far, I believe the subprocess might do the trick, however, I am not able to open the JSON file ...
0votes
0answers
20views
Why does json.load give me an error even though I use the "with" "syntax"? [duplicate]
I have recently been interested in data and JSON files. I uploaded a file named "sarcasm.json" onto the computer and coded this out.
import json
with open("sarcasm.json", 'r') as ...
0votes
0answers
28views
Python json schema validator
Hello guys i have a problem to validate a basic nested json.
this is my current json : sample_v7.json
{
"vcn_keys": {
"name_1": {
"compartment_id": "...
0votes
0answers
15views
Python3 parsing json file and writing to csv
I'm trying to parse a JSON file to CSV.
I'm having trouble getting ONLY the values of the json object to appear in their corresponding columns instead of having the key AND value appear in each column ...
0votes
1answer
19views
JSON serialization of an array of custom objects with additional data with JSONEncoder
I have an array of custom objects (lightning records) that I serialize without any problems with my custom encoder:
class LightningJSONEncoder(json.JSONEncoder):
def default(self, obj):
if ...
0votes
1answer
28views
Python JSON get value by string path
I have a JSON file that I want to automatically check specific values,
like: myJSON['generic']['lessgeneric']['store'] should be equal to 100,
I was thinking of doing something like this:
checks = [
...
0votes
3answers
62views
How to convert CSV to nested JSON in Python
I have a csv file in the following format:
a
b
c
d
e
1
2
3
4
5
9
8
7
6
5
I want to convert this csv file to Nested JSON format, like this:
[{"a": 1,
"Purchase" : {
...
0votes
0answers
18views
Convert nested json to multiple dataframes - dynamically
i have a question:
Is it possible read a json file and convert to dataframe dynamically?
My example is the next code:
Having this json file, i need 3 table dataframes:
{
"date_time": "...
0votes
0answers
29views
Randomize questions and options together
{
"question": [
"The person signing cremation authorization, giving permission for the cremation to take place?",
"Receptacle used to transport and house the body ...
0votes
1answer
32views
Json normalize an array of objects
i need some help to normalize a json structure and convert it to dataframe
this is my example:
# importing the libraries used
import pandas as pd
# initializing the data
data = {
'company': 'XYZ ...
1vote
2answers
56views
extend dataframe with rows containing dictionary in list
I have about 300.000 rows as below, but what I need is only id and email address. Dataframe like this:
d = {'vid': [1201,1202], 'col2': [[{'vid': 1201, 'saved-at-timestamp': 1638824550030, 'deleted-...
1vote
1answer
35views
Merge multiple values for same key to one dict/json (Pandas, Python, Dataframe)?
I have the following dataframe:
pd.DataFrame({'id':[1,1,1,2,2], 'key': ['a', 'a', 'b', 'a', 'b'], 'value': ['kkk', 'aaa', '5', 'kkk','8']})
I want to convert it to the following data frame:
id value
...
0votes
1answer
41views
In json sorting ,my output getting duplicate
why my code create duplicate value in my list
{"name":"Sheet1!A1:M26","rows":[[{"v":"Date"},{"v":"Release"},{"v":"...
0votes
0answers
6views
I wanted sigup button to give the value to my funtion which writes the value in json but I don't know how to
def signup_page(filename="accounts.json"):
top = Toplevel()
top.title("Sign up page")
top.geometry('700x600')
top.resizable(False,False)
signup_label = Label(...
0votes
3answers
33views
how do i add a reference to a python function in a json file
I have a dictionary that contains references to different functions.
I was trying to make my code more readable and make it easier to add functions to this dictionary.
I was trying to convert my ...
0votes
1answer
36views
How do I organize a custom dict (with string elements)?
I receive this dict in my system, with string values, and I need to organize it in a custom way.
kafka_data = {
"flush_size": "1000",
"branch": "develop"...
-1votes
1answer
33views
How can I remove one element in a json string in Python? [duplicate]
I have this payload:
payload = {
"cluster": "analytics",
"id_pipeline": "123456789",
"schema_compatibility": "backward",
&...
0votes
0answers
18views
"TypeError: Decimal(x) is not JSON serializable" when trying to do json.dumps method on Python [duplicate]
I receive this dict in my application:
payload = {
'avro_schema': '{"type":"record","namespace":"Tutorialspoint","name":"Employee","...
1vote
1answer
35views
How to Calculate unique statuses in a JSON dataset file
I have a dataset of JSON File
[
{
"id": 333831567,
"pieceId": 25395616,
"status": 10800,
"userId": 911,
"startTime": ...
0votes
1answer
23views
How to convert a DynamoDB Json in a regular JSON in Python?
I get a json from DynamoDB and that is the format:
payload_stack = {'Records': [{'eventID': '123456', 'eventName': 'INSERT', 'eventVersion': '1.1',
'eventSource': 'aws:dynamodb', '...
0votes
1answer
22views
How to merge/append two json array list in python in a specific way
I have two list of Json array output,
x =
[
{
"id": "5019",
"tiClass": "Device",
"tiSubclass": "Virtual Machine",...
0votes
1answer
33views
Create class using getter-setter which gets data from json using python3
I'm building an application using REST APIs for a 3rd party application. When I retrieve an object from the API it sends me a json which I pass into a class that internally takes out keys and provides ...
0votes
0answers
43views
Panda DataFrame Groupby within Groupby, or nested Groupby
I use the pandas dataframe and I try to get output as json. I want it to be grouped in its sub-objects in json, but I couldn't.
how can I create nested objects. I have shared my output and the output ...
0votes
1answer
32views
Return the correct status searching the records
Task description:
Please provide an implementation that searches the records and returns the correct user_status at the given date. You can imagine the records as single events which get fired on a ...
0votes
1answer
19views
Using Environment Variables as Credentials on Heroku
I need to make the "google-credentials.json" file works on heroku it's working locally by putting the local path on my laptop but in heroku I don't know how to do it.
I search a lot, I found ...
0votes
0answers
29views
Convert Nested Json Schem to Pyspark Schema
I have a schema which has nested fields.When I try to convert it with:
jtopy=json.dumps(schema_message['SchemaDefinition']) #json.dumps take a dictionary as input and returns a string as output.
...
0votes
1answer
25views
Trying to recursively populate a ttk.treeview with json/dictionary in python
I am new to python, but have java experience. Pretty different animals. I have a method that creates a json/dictionary based on walking through a directory structure and I have it where it creates a ...
-1votes
1answer
24views
Python how to transform the below into a nice list of json object (like i would get from an API)
This is the format of data i have:
('Domain Name,Start Date,End Date,Attributed To,Tags\r\n'
'domain.com,2011-01-01,Active,Company A SA,\r\n'
'domain.com,2011-01-01,Active,Company A SA,\r\n'
'...
0votes
0answers
15views
How can I get this function to append an extracted value from API to list every 60 seconds?
I'm wanting to extract values from API every 60 seconds and store them to a list but when I execute the while loop it stores the values in separate lists. I want the values pulled every 60 seconds to ...
-2votes
1answer
26views
Create nested json from list of dicts and list of strings
I have 3 list of dicts and a list of strings that I need to convert into json format. TBH, I am not sure where to begin but if anyone can point me in the right direction, that will be super helpful
...
0votes
2answers
69views
fast API return image as json
I have got an API for random tea photos but would like it to return the photo in JSON as a URL for discord bots and things. This is what I have so far
def getRandomFile(path):
"""
...
0votes
1answer
30views
How to process Json file with column headers and data separated in different lists in spark
I have Json file as follows:
{"columns": ['Name', 'City', 'DOB'],
"data":[
['ABC', 'Georgia', '01/05/1987'],
['ABC', 'Kansas', '10/11/1989']]}
How can this file be ...
1vote
0answers
24views
finBert Model - Config JSON File - Outputs Nothing
This is for running the ProsusAI finBert Model.
(https://github.com/ProsusAI/finBERT - GitHub)
(https://huggingface.co/ProsusAI/finbert - HuggingFace)
I downloaded the pytorch_model.bin file and used ...
-1votes
2answers
30views
How would I be able to get a value from JSON?
I am trying to retrieve a value of a JSON file, but I keep getting the error
/home/pi/Desktop/asd.py:5: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
...
0votes
1answer
30views
Python - Validate all rows in JSON file against schema
I am trying to validate all rows in my JSON data file against the schema without looping through each data entry in the JSON file.
However when just passing in the entire JSON file no validation ...
0votes
1answer
38views
How to handle .json fine in tabular form in python?
By using this code:
import pandas as pd
patients_df = pd.read_json('/content/students.json',lines=True)
patients_df.head()
the data are shown in tabular form look like this:
The main json file looks ...
-2votes
3answers
97views
Accessing object elements in list
I get the response of a server:
r = requests.get(my_url)
print(r.text)
json_response = json.loads(r.text)
print(type(json_response))
I am using json.loads() to convert the string into json. However, ...
0votes
0answers
30views
Lambda function unable to retrieve all messages in SQS queue using boto3, only prints 1st message
A bit new to SQS using boto3 in lambda functions.
My Lambda function does not retrieve all messages in the SQS queue using boto3, it only prints the first message even though the goal is for all the ...
1vote
1answer
52views
Converting a String to json [closed]
The string below I believe is in json format but when I try to
load string into a json variable so I can easily query and extract the data points it errors out.
jdata = '<pre>{\n "askId&...
0votes
1answer
20views
Helper function to normal format in python
i am working in arq worker, while testing some code, i was getting like this format
JobDef(function=<function helper at 0x7f79b3582f70>, args=(4, 5, 6, 6), kwargs={}, job_try=None, enqueue_time=...
-2votes
2answers
35views
Parse a file which is a lists of objects in Python [closed]
I have a json-like file in the below format, I would like to store the BLEU score attribute in a list and the chrF2++ score in another list.
The file format:
[
{
"name": "BLEU",
&...
-1votes
0answers
25views
Python search by json key and first value
So I have json format like so
key : value1, value2, value3
How can I return rows or collections whatever you want the call them (the entire key and values pair), where the key is equal too X and ...
-1votes
1answer
41views
JSON-ify string
Are there any faster ways to JSON-ify a string? I first escaped manually, then tried json.dumps as suggested below, but can I somehow use repr() too?
import timeit, json
def escape_str(string):
...
0votes
0answers
6views
Python Replacing json file contents
I am working on an project where I shall get json results with HTTP request and send it to ElasticSiem. For doing this I will have results separated by new line
The results I get are in this form
{&...
0votes
0answers
18views
Request Response Headers different to Web browsers
I am working on a Bot to purchase me an item as it's hard to get. I have got to the payment stage and need to make one more post. It requires a link returned by a header in a post before this one.
The ...
-1votes
1answer
30views
How to find and replace a value in a JSON file?
I have a discord.py bot and also a java discord bot that stores prefixes in a JSON file, I need a python script that adds or replaces the "prefix" value with python for a string that I ...