Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!