It will give
To make it more robust change to this.
KeyError
if a line pass trough and can not do a dictionary call.To make it more robust change to this.
for index,line in enumerate(data): try: res = data[index].strip().split('[audit] ')[1] result = literal_eval(res) #print(result) timestamp = result['timestamp'] user = result['user']['username'] print(timestamp) print(user) except KeyError: pass #print(res) # lines that fail