I have the following script. Currently I run the script and in shell redirect the output to file. I would like to create this with python itself so that I can use the script