Borland & Photosight
Photosight Photosight
Hey Borland, I’m on a quest to map every little detail of a rare beetle’s habitat, but my notes keep getting lost in the data. Any chance you could help me build a simple log system that keeps track of light, humidity, and that beetle’s movements?
Borland Borland
Sure thing! Let’s keep it ultra‑simple: a tiny Python script that writes a row to a CSV each time you log a reading. ```python import csv, datetime LOGFILE = 'beetle_log.csv' def init_log(): # If file doesn’t exist, create header row try: with open(LOGFILE, 'x', newline='') as f: writer = csv.writer(f) writer.writerow(['timestamp', 'light_lux', 'humidity_%', 'movement']) except FileExistsError: pass def log_reading(light, humidity, movement): timestamp = datetime.datetime.now().isoformat() with open(LOGFILE, 'a', newline='') as f: writer = csv.writer(f) writer.writerow([timestamp, light, humidity, movement]) # Usage example init_log() log_reading(350, 68, 'none') ``` Run `python yourscript.py` whenever you want to capture a new set of data. You’ll get a neatly‑formatted CSV you can open in Excel or import into a database later. Keep the script in a folder with your data, and it’s all there, no notes getting lost. Happy logging!