0

First let me say that this community has provided valuable support to my coding education. I've written a program to manage a small nursery in Python for the RPI3. I created a configuration csv file to change key parameters without having to reboot the program. I've attached the code below. Am I going about this correctly or would a more experienced programmer utilize a different method? Thanks in advance for your feedback.

def read_configuration():
    with open('/home/pi/grow_config.csv', newline='') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        temp_high = row['temp_high']
        temp_low = row['temp_low']
        moisture_high = row['moisture_high']
        moisture_low = row['moisture_low']
        light_high = row['light_high']
        light_low = row['light_low']
    csvfile.closed    

OUTPUT

%Run read4.py 80 72 50000 32000 20000 20000

JoeG
  • 9
  • 1
  • Suggest you take a look at Python's [`confiparser`](https://docs.python.org/3/library/configparser.html#module-configparser) module instead of re-inventing the wheel. JSON format files are also relatively easy to handle using the [`json`](https://docs.python.org/3/library/json.html#module-json) module. There's also the [`pickle`](https://docs.python.org/3/library/pickle.html#module-pickle) module, which is a Python-specific, but relatively easy to [use](https://stackoverflow.com/questions/4529815/saving-an-object-data-persistence). – martineau Apr 11 '19 at 00:46
  • Thank you martineau – JoeG Apr 11 '19 at 21:31

0 Answers0