For a program I'm working on I have a text file that contains something similar to this:
{0: {2: 1, 1: 1}, 1: {2: 1, 0: 1}, 2: {0: 1, 1: 1}}
where essentially the first number is an index for a node, and the following is a list of follow up nodes this node is connected to, and their weights. I was wondering the best way to be able to grab a single set enclosed in a pair of {}'s, so I would end up with something like this:
0:
{2: 1, 1: 1}
1:
{2: 1, 0: 1}
Currently my plan is to find the index of the first colon and take what is between the open bracket and that colon as the ID, then find the next open bracket and following colon to get the following set of nodes however it is quickly becoming complicated for much larger lists and was wondering if there was a better method