Since the data in your input file isn't really in JSON or Python object literal format, you're going to need to parse it yourself. You haven't really specified what the allowable keys and values are in the dictionary, so the following only allows them to be alphanumeric character strings.
So given an input file with the following contents nameddoc.txt
:
{key1: value1
key2: value2
key3: value3
}
{key4: value4
key5: value5
}
The following reads and transforms it into a Python list of dictionaries composed of alphanumeric keys and values:
from pprint import pprint
import re
dictpat = r'\{((?:\s*\w+\s*:\s*\w+\s*)+)\}' # note non-capturing (?:) inner group
itempat = r'(\s*(\w+)\s*:\s*(\w+)\s*)' # which is captured in this expr
with open('doc.txt') as f:
lod = [{group[1]:group[2] for group in re.findall(itempat, items)}
for items in re.findall(dictpat, f.read())]
pprint(lod)
Output:
[{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'},
{'key4': 'value4', 'key5': 'value5'}]