Assumptions
- You have a
.txt
file.
- Format of a line is
[["arg1", "arg2", "arg3",...etc.], "Fail/Pass"]
Approach is to use regex to find all text between double quotes and append to the list. The last one is taken as "Fail/Pass" and rest of them are args.
import re
result = []
with open('text.txt','r') as f:
for line in f:
match = re.findall("\"(.*?)\"",line.strip())
result.append([match[:-1],match[-1]])
print(result)
print(result[0][0])
print(result[0][1])
Sample Input .txt
file
[["arg1", "arg2", "arg3","arg4"], "Fail"]
[["arg1", "arg2", "arg4"], "Pass"]
Output
[[['arg1', 'arg2', 'arg3', 'arg4'], 'Fail'], [['arg1', 'arg2', 'arg4'], 'Pass']]
['arg1', 'arg2', 'arg3', 'arg4']
Fail