This is my code below. When I run it i get the error:
c:\Users\renne\Documents\Code\Text Analysis\Assignment1.1C.py:27:
FutureWarning: Possible nested set at position 54
for item in
re.finditer("(?P<host>\d{3}[.]\d{3}[.]\d{3}[.]\d{3})(?P<user_name>[[\w]+\d{4}]|[-])(?P<time>\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2} -\d{4})(?P<request>[A-Z]+ \S* HTTP/\d[.]\d)", logdata):
I dont know how to solve this. I have looked over my code a few times and cant figure out the problem.
I used a random string out of the test data instead of the enire txt file to make the testing easier. When this works ill change logdata = '...' to a read.
import re
logdata = '146.204.224.152 - feest6811 [21/Jun/2019:15:45:24 -0700] "POST /incentivize HTTP/1.1" 302 4622'
dict = {}
expression = """
(?P<host>\d{3}[.]\d{3}[.]\d{3}[.]\d{3})
(?P<user_name>[[\w]+\d{4}]|[-])
(?P<time>\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2} -\d{4})
(?P<request>[A-Z]+ \S* HTTP/\d[.]\d)
"""
for item in re.finditer("(?P<host>\d{3}[.]\d{3}[.]\d{3}[.]\d{3})(?P<user_name>[[\w]+\d{4}]|[-])(?P<time>\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2} -\d{4})(?P<request>[A-Z]+ \S* HTTP/\d[.]\d)", logdata):
print(item.groupdict()['host'])
print(item.groupdict())