def update_logs_html(): day = get_timestamp().split()[0] csv_path = '/home/pi/Pi_Weather_Station/src/logs/' + day + '.csv' columns = [ 'Log Time', 'Temp (C)', 'Temp (F)', 'Humidity', 'Pressure', 'DewPoint', 'X', 'Y', 'Z', 'Weather', 'AQI' ] df = pd.read_csv(csv_path, names=columns) with open('/home/pi/Pi_Weather_Station/src/templates/logs.html', 'w') as html_file: html_file.write(df.to_html())
def get_csv_data(): """Open the daily csv log and return the content""" csv_list = [] day = get_timestamp().split()[0] csv_path = os.path.join(os.path.dirname(__file__) + '/logs/', day + '.csv') # csv_path = '/home/pi/Pi_Weather_Station/src/logs/' + day + '.csv' with open(csv_path, 'r') as csv_file: # content = f.read() csv_reader = csv.reader(csv_file, delimiter=',') for row in csv_reader: # print(row) csv_list.append(row) return csv_list
def logs_web(): day = get_timestamp().split()[0] csv_path = os.path.join(os.path.dirname(__file__), day + '.csv') with open(csv_path, 'r') as f: content = f.read() return render_template('logs.html', content=content)