I have the following exported text file:
14:00:01 type1 "xyz" has no relationships... ಠ_ಠ
14:00:01 type2 "xyza" has no relationships... ಠ_ಠ
14:00:01 type2 "aaaa" has no relationships... ಠ_ಠ
14:00:01 type3 "asdg" has no relationships... ಠ_ಠ
14:00:01 type4 "dhj" has no relationships... ಠ_ಠ
I'm trying to find a way to retrieve two informations from this file
- The type (in this case, the element after the time and before what is inside the double quote)
- What is inside the double quote
Output expected:
type1 xyz
type2 xyza
type2 aaaa
type3 asdg
type4 dhj
With my current code, I can get the content inside the double quote, but I don't know how to get the type and merge it with my regex:
import os, yaml
import argparse
import re
with open('stackoverflow.txt') as f:
content = f.readlines()
matches=re.findall(r'\"(.+?)\"',str(content))#get the content within the double quote
for x in matches:
print(x)
Current output:
xyz
xyza
aaaa
asdg
dhj