My real question to the experienced programmers of this community is if using the code below actually creates a new file if it does not exist?
Code: Select all
from gpiozero import CPUTemperature
from time import sleep, strftime, time
with open("/media/pi/RPI4B/Videos/Pi_Camera_Videos/cpu_temp.csv", "a") as log:
while True:
temp = CPUTemperature()
log.write("{0}, {1}°C\n".format(strftime("UTC: %Y-%m-%d %H:%M:%S"),str(temp)[-6:-1]))
sleep(1)
Does this mean that the modified example creates a file (in my case a csv file for logging the CPU temperature) when it "sees" that cpu_temp does not exist? Or am I missing something here?