Part C Consider the standard web log file in assets/logdata.txt. This file records the access a user makes when visiting a web page (like this one!). Each line the log has the following items: • a...


Part C<br>Consider the standard web log file in assets/logdata.txt. This file records the access a user makes when visiting a<br>web page (like this one!). Each line<br>the log has the following items:<br>• a host (e.g., '146.204.224.152')<br>a user_name (e.g., 'feest6811' note: sometimes the user name is missing! In this case, use '-' as the value<br>for the username.)<br>• the time a request was made (e.g., '21/Jun/2019:15:45:24 -0700')<br>• the post request type (e.g., 'POST /incentivize HTTP/1.1' note: not everything is a POST!)<br>Your task is to convert this into a list of dictionaries, where each dictionary looks like the following:<br>example_dict = {

Extracted text: Part C Consider the standard web log file in assets/logdata.txt. This file records the access a user makes when visiting a web page (like this one!). Each line the log has the following items: • a host (e.g., '146.204.224.152') a user_name (e.g., 'feest6811' note: sometimes the user name is missing! In this case, use '-' as the value for the username.) • the time a request was made (e.g., '21/Jun/2019:15:45:24 -0700') • the post request type (e.g., 'POST /incentivize HTTP/1.1' note: not everything is a POST!) Your task is to convert this into a list of dictionaries, where each dictionary looks like the following: example_dict = {"host":"146.204.224.152", "user_name":"feest6811", "time":"21/Jun/2019:15:45:24 -0700", "request":"POST /incentivize HTTP/1.1"} In [ ]: import re def logs(): with open ("assets/logdata.txt", "r") as file: logdata = file.read() # YOUR CODE HERE raise NotImplementedError(() In [ ]: assert len(logs()) == 979 one_item={'host': '146.204.224.152', 'user_name': 'feest6811', 'time': '21/Jun/2019:15:45:24 -0700', 'request': 'POST /incentivize HTTP/1.1'} assert one_item in logs(), "Sorry, this item should be in the log results, check your 1

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here