c. log file parser
A coding challenge
Objective
Write an application that reads data from an external file, stores it in a suitable data structure, and processes it to output summary statistics. This will test your file handling skills and your ability to parse structured text.Timestamp,LogLevel,Message
2026-09-06 08:01:12,INFO,Server started successfully
2026-09-06 08:05:33,INFO,User admin logged in
2026-09-06 08:12:04,WARNING,High memory usage detected
2026-09-06 08:15:22,INFO,Database backup completed
2026-09-06 08:22:45,ERROR,Failed to connect to database
2026-09-06 08:30:11,INFO,User jsmith logged in
2026-09-06 08:45:09,WARNING,Unauthorised access attempt
2026-09-06 08:50:15,INFO,File uploaded successfully
2026-09-06 09:01:02,ERROR,Timeout writing to disk
2026-09-06 09:15:33,INFO,Scheduled maintenance started
2026-09-06 09:20:01,ERROR,Service crashed unexpectedly
2026-09-06 09:25:10,INFO,Service restarted
Requirements
Save the provided server log data into a plain text file named server_logs.csv in the same directory as your program.Write a program that opens server_logs.csv in read mode.
Read the contents of the file line by line.
Split each line into its constituent parts (Timestamp, Log Level, and Message).
Calculate and output the following summary statistics:
The total number of log entries (excluding the header row).
The total number of INFO messages.
The total number of WARNING messages.
The total number of ERROR messages.
Stretch Goal
Modify your program so that it writes all of the ERROR entries into a brand new text file called error_report.txt.Last modified: September 6th, 2026
