I'm trying to read a txt file containing multiple dictionaries. The file has the following format:
/* 1 */
{
key1: val1,
key2: val2
}
/* 2 */
{
key1: val1,
key2: val2
}
/* 3 */
{
}...
I'm trying to read it as a list of dictionaries. Is there any way to remove that /* x */ thing and do the needful? I tried the following piece of code but it doesn't seem to work:
import ast
with open('doc.txt') as f:
data = f.read()
d = ast.literal_eval(data)