I have text file in this manner
{ a 3 56 cd 8 }
{ 1 2 3 4 ab 546 }
I am currently using the following line to parse it into a list of list
for line in filename.readlines():
line = line.lstrip('{').rstrip('}\n').strip(' ').split(' ')
Is this the best way to do this?
Because I have heard people say that the split function should be seldom used as it slows down the script considerably.
EDIT:
I expect the output to be:
[[a,3,56,'cd',8],[1,2,3,4,'ab',546]]
Assuming there is no whitespace before the openening and after the closing bracket:
or if I can’t assume that: