-
Book Overview & Buying
-
Table Of Contents
Python Automation Cookbook - Third Edition
By :
Another common structured text file format is used in log files. These consist of rows of log data, which are lines of text having a particular format suited to describing events.
Different applications can generate very different log formats and there's no common structure or syntax for them
Typically, each log entry will have a time when the event occurred, so the file is an ordered collection of event entries.
The example_log.log file, containing five sales logs, can be obtained from the GitHub repository here: https://github.com/PacktPublishing/Python-Automation-Cookbook-Third-Edition/blob/main/ch04/documents/example_logs.log.
The format in this case is:
[<Timestamp in iso format>] - SALE - PRODUCT: <product id> - PRICE: $<price of the sale>
We'll use the ch01/price_log.py file, introduced in Chapter 1, to process each log into an object. There's a copy in the ch04/documents directory to simplify the import process...