Another common structured text file format is log files. Log files consist of rows of logs, which are a line of text with a particular format. Typically, each one will have a time when it happened, so the file is an ordered collection of events.
Reading log files
Getting ready
The example_log.log file with five sales logs can be obtained from the GitHub repository here: https://github.com/PacktPublishing/Python-Automation-Cookbook/blob/master/Chapter04/documents/example_logs.log.
The format is the following:
[<Timestamp in iso format>] - SALE - PRODUCT: <product id> - PRICE: $<price of the sale>
We'll use the Chapter01/price_log.py file to process each log into an object.