Have you attempted anything? I won't do your work for you. I will suggest the following steps:
Read the file.
Parse the data.
Initialize a dictionary to store the data in an organized fashion.
Iterate on the data.
If the line of data has a colon (:), split the data and add to dictionary as in:
- >>> line = "FACILITY : BACKUP"
-
>>> dd = {}
-
>>> line_list = [item.strip() for item in line.split(":")]
-
>>> line_list
-
['FACILITY', 'BACKUP']
-
>>> dd.setdefault(line_list[0], []).append(line_list[1])
-
>>> dd
-
{'FACILITY': ['BACKUP']}
-
>>>
If the line of code contains "FAILED":
- >>> line = "FAILED LOGINACCOUNTINGTST"
-
>>> if "FAILED" in line:
-
... dd.setdefault("FAILED", 0)
-
... dd["FAILED"] += 1
-
...
-
-
>>> dd
-
{'FAILED': 1, 'FACILITY': ['BACKUP']}
-
>>>
After the data has been organized into a dictionary, create a CSV (comma separated value, the csv module is ideal for this) file for opening in Excel or write directly into Excel format with the
xlwt module.