Skip to content

Tag: json

slow update of large JSON File

I have a large JSON file that contains serialized json dicts. I am trying to iterate this file and update based on the contents of another dict. The JSON file looks similar to: The function below, iterates each line of the JSON file and creates a “key_value” that’s a concatenation of item an…

Creating a nested dictionary from a pandas dataframe

I have a dataframe which demonstrates a hierarchy of meters. A meter has an ID, and can have any number of children, this children can also have children, which can also have children, ad infinitum. The dataframe has a meter per row, and the level of the child is shown by column. As shown below: The aim is to…

How do I read and then update a json file?

I need to be able to update a json file in python. I can get it to create and write to the json file the first time, but it keeps telling me I have an json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0). Here’s the code: Here’s the full traceback. I’m using Python 3.9.2. …

How to create a JSON file from SQL query?

I am creating a JSON file from a SQL query. But I could not create truly. The problem is there is a “items” object and it has products. But mine create products directly not in “items” objects. The Code. yields the following JSON object as a result while the desired one should be as fo…

How to store input values from user in json format?

I used below code to store student information but I get only one value appearing in the json file. Answer It is because you are overwriting your file after each while loop. Do the writing to file outside. Also, You want to store student into list.