I have some text stored in a file which looks like this:
[10, 1575311969.9649343, 'Hot Brew', 10, True, 'No tank', 'Organic Red Helles']
[101, 1575311971.3570273, 'Hot Brew', 10, True, 'No tank', 'Organic Red Helles']
Now, I want to get this in my code as a 2d list:
batches = [[10, 1575311969.9649343, 'Hot Brew', 10, True, 'No tank', 'Organic Red Helles'],
[101, 1575311971.3570273, 'Hot Brew', 10, True, 'No tank', 'Organic Red Helles']]
I tried using the code
from ast import literal_eval
with open('runBatchBackup.txt', 'r') as f:
batches = literal_eval('[' + f.read() + ']')
But this resulted in
ValueError: malformed node or string: <_ast.Subscript object at 0x03C72BB0>
How can I convert my text file into the format I want?