I need to process a series of data, where each line has the user ID and the data I want to process. I thought a good solution would be to read these files and create a JSON where the keys are the ids and the values are all the data associated with that id.
[
id1 :
{
name: "..."
age: "..."
date_of_birth: "..."
},
id2 :
{
name: "..."
age: "..."
date_of_birth: "..."
},
...
]
However, I'm not sure how I can dynamically add more information to the objects associated with the ID. At each reading of the line of my file, I must look in my dictionary for the ID. If there is already a record of this ID in the dictionary, I should just add a new line in the object associated with it. Otherwise, I must create this key/value pair and add a new line to the object associated with it. Preferably, I would like to build this dictionary in descending order of ids. Any idea how I can build this structure?