Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

New Method Create a method called parse ( ) . It must accept an argument that contains an integer value representing the month ( 1

New Method
Create a method called parse(). It must accept an argument that contains an integer value representing the month (1-12). Hint: Command line arguments are strings by default!
In this method, use a list comprehension to filter ONLY the log entries whose event_time matches the month of the argument.
Print the number of log entries from this month to the screen.
New Argument
To implement this action, you will need to accept a new NON-REQUIRED command line argument --month, or -m
Implement the New Method
Update your program to allow the user to provide the value parse to the --action argument.
If the user chooses this action, verify that they have passed in a valid month (it will be an integer from 1-12).
If the month is valid, call the parse() method and pass the value of the --month argument.
View the Result
The command
python index.py --filename firewall_logs_2022.csv --action parse --month 11
Should result in a print() statement that says the following (the number will be different based on the data):
12,345 log entries were recorded in month 11.
Export Data (up to 15 points)
If a user correctly executes the command to parse a specific month of data, also add the functionality that writes ONLY the events that occurred in that month to a new CSV file.
For example, if the user chose 11 as their month, your program should produce a CSV file named 2022_11_logs.csv
Hints and Tips
You can use the csv.DictWriter module to create a CSV file
Remember that the imported data in your program is stored as a list of objects of class LogEntry. You will need to convert the filtered objects into dictionaries before using DictWriter.
Your CSV file should contain a header row that labels all the columns in the remaining rows of your CSV file (it should have the same structure as the firewall_logs_sample.csv file).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago