Creating a simple report in plain text
The simplest possible way to create a report is to generate plain text and store it in a file. Though this may seem simplistic in comparison with other formats that we will see later, don't underestimate its utility. Plain text is the easiest format to share as it will work in virtually all environments, and textual information can go a long way in representing information.
Getting ready
For this recipe, we will generate a brief report in text format about the number of watched movies in the last month and total time. Internally, the original data to be represented will be in the shape of a Python dictionary. The report will include the generation date as well, for reference.
How to do it...
- Import
datetime
:>>> from datetime import datetime
- Create the template with the report in text format:
>>> TEMPLATE = ''' Movies report ------------- Date: {date...