file = open(fname, 'r')
codes = re.findall('LIR: (.+)', file.read())
functions = re.findall(';(.+);LIR', file.read())
Im trying to extract 2 different strings from every 1 line in single file.
It gets
SyntaxError: unexpected EOF while parsing
file = open(fname, 'r')
codes = re.findall('LIR: (.+)', file.read())
functions = re.findall(';(.+);LIR', file.read())
Im trying to extract 2 different strings from every 1 line in single file.
It gets
SyntaxError: unexpected EOF while parsing
The first time your code calls file.read()
it is reading the whole file. The second time your code calls it, without first closing the file and reopening it, it is at EOF.
If you want to extract stuff from individual lines of the file then iterate through the file:
codes = []
functions = []
with open(fname,'r') as file:
for line in file:
codes.extend(re.findall('LIR: (.+)',line))
functions.extend(re.findall(';(.+);LIR', line))