I need to track the status of firewall rule requests and provide a status report every Monday. The requests are managed through a website where I can see the list of uncompleted requests and their status, but the site doesn't give me a count of the number of requests in each of the states that a request can be in, which can be "Pending Approval", "Modified", "Pending Removal" "On Hold", "Clarification Required", "Waiting Implementation", or "Waiting Removal". To obtain the count of the number of requests in each state, I download the webpage showing the requests and their status to my laptop and then run a Python script to count the queued items. But I also want to see how the numbers are changing over time, so I modified the script to write the counts to a comma-separated values (CSV) file that I can open in a spreadsheet program, such as Microsoft Excel.
To work with comma-separated value (CSV) files in a
Python script, include the command
in the script. I also include the
os.path module to use for
testing whether a file already exists that will hold the data, the
re module to perform
regular expression parsing of lines in the downloaded webpage,
sys module for checking the command line
arguments to the script, and the
module for determining the current date and formatting it in YYY-MM-DD
format, where "YYYY" is the year, "MM" the month, and "DD" the day of the
month, as explained in Python -
Checking times and dates, for writing the date to the output file.
[ More Info ]