X-Git-Url: https://git.toastfreeware.priv.at/toast/airingbutler.git/blobdiff_plain/542c509c47cdae3a08d4217940c6cfb2ccfcd0fc..d6f99b9cb83e0506b1cef2e076dbd4715923c620:/plot_mhz19.py?ds=sidebyside diff --git a/plot_mhz19.py b/plot_mhz19.py index 4d3b90a..defb0da 100755 --- a/plot_mhz19.py +++ b/plot_mhz19.py @@ -5,8 +5,8 @@ import argparse from datetime import datetime, date, timedelta from matplotlib import pyplot as plt -filename = 'log.csv' ''' +filename = 'log.csv' Time,TS,CO2,Temp 21:02:02,0,661,24 21:02:08,5021,657,24 @@ -19,17 +19,19 @@ def parsedatetime(timevalue, currentdate): def main(): parser = argparse.ArgumentParser('Plot log.csv.') - parser.add_argument('--temperature', '-t', action='store_true', help='Include temperature plot') + parser.add_argument('filename', nargs='?', default='log.csv', help='Name of csv file') + parser.add_argument('-s', '--startdate', nargs='?', default='2020-10-22', help='First date in csv file') + parser.add_argument('-t', '--temperature', action='store_true', help='Include temperature plot') args = parser.parse_args() + startdate = datetime.strptime(args.startdate, '%Y-%m-%d').date() - with open(filename) as f: + with open(args.filename) as f: reader = csv.reader(f) headers = next(reader) time = [] co2 = [] temp = [] - startdate = date(2020, 10, 22) for row in reader: dt = parsedatetime(row[0], startdate) if len(time) > 0 and dt - time[-1] < timedelta(hours=-2): # DST switch!