I'm generating a dict from a JSON file, and I want to append all the values that have the same beginning under one key. I don't really know how, I suppose that I should use something from re and tag everything that matched with the beginning?
Here's a sample of the JSON:
[{..."derived-missing_residues-mobi-2btp_A":{'stuffgoeshere'},'derived-missing_residues-mobi-6bcr_A':{'morestuffgoeshere'}}]
As you can see, they all share the 'derived-missing_residues-mobi-" part. It only changes at the end.
And the code that I have is really simple:
import json
dict_name = dict.fromkeys(['...','MISSING',])
with open("path\Json1.json") as f:
data = json.loads(f.read())
for i in data:
if 'derived-missing_residues-mobi-' in i: #Here I should be using re, somehow.
dict_name['MISSING']=(i['MISSING'])
something with re.findall(r'.*',derived-missing_residues-mobi-)
could do the trick but I'm not really familiar with the library.
Thanks in advance!