Since the data in your input file is actually not in JSON or Python, you will need to parse it yourself. You really haven't indicated which valid keys and values ββare in the dictionary, so the following only allows them to be alphanumeric character strings.
So, the given input file with the following contents is named doc.txt :
{key1: value1 key2: value2 key3: value3 } {key4: value4 key5: value5 }
The following reads and converts it into a list of Python dictionaries, consisting of alphanumeric keys and values:
from pprint import pprint import re dictpat = r'\{((?:\s*\w+\s*:\s*\w+\s*)+)\}'
Conclusion:
[{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}, {'key4': 'value4', 'key5': 'value5'}]
source share