-
Notifications
You must be signed in to change notification settings - Fork 0
/
warm_rooms.py
31 lines (25 loc) · 1.27 KB
/
warm_rooms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
import time
import csv
start_time = time.time()
temp_max = 75
temp_units = "deg F"
co2_units = "ppm"
new_data = pd.read_csv('/media/ea/Data/Students/jade/buildingEnergyApi/ahs_air_data.csv', delimiter=",", names=['Time Stamp', 'Room Number', 'Temperature', 'Temperature Units', 'CO2', 'CO2 Units'])
new_data = new_data.sort_values(by='Room Number')
print("Full CSV: ")
print(new_data)
# print(new_data[new_data.Location == '270.01'][['Room Number', 'Temperature', 'CO2']])
# print("\nToo Hot: \n")
warm_data = new_data[new_data.Temperature > temp_max][['Room Number', 'Temperature', 'CO2']].sort_values(by='Temperature')
with open('/media/ea/Data/Students/jade/buildingEnergyApi/ahs_warm_data.csv', 'a') as permanent_warm_data:
temp_writer = csv.writer(permanent_warm_data, delimiter=';')
current_time = time.asctime()
for index, row in warm_data.iterrows():
temp_rn = row['Room Number']
temp_squared = row['Temperature']
temp_carbon = row['CO2']
temp_writer.writerow( ['{0},{1},{2},{3},{4},{5}'.format( current_time, temp_rn, temp_squared, temp_units, temp_carbon, co2_units) ])
# Report elapsed time
elapsed_time = round( ( time.time() - start_time ) * 1000 ) / 1000
print( '\nElapsed time: {0} seconds'.format( elapsed_time ) )