I got temperature, pressure, and altitude readings on my PI using a sensor:

The problem is, to see the results, I have to execute the code.py every time by myself. I am trying to automate it somehow so it will keep running itself for the time I want. 
Once that is automated, would like to save the results and analyze the output after some time.

Is there a way I can write code for both the tasks?
Thank you.
The time module is your friend here. You can set up an infinite loop with while True: and use time.sleep(secs) at the end of the loop (after output).
How to write an autoscript in Python?