diff --git a/energy_validation.py b/energy_validation.py index b86edb2..a6b173d 100644 --- a/energy_validation.py +++ b/energy_validation.py @@ -80,21 +80,22 @@ class EnergyValidation: demand *= 0.001/building_area # replace indexes with month/day/year format - months = {'month': - ['1/1/2023', - '2/1/2023', - '3/1/2023', - '4/1/2023', - '5/1/2023', - '6/1/2023', - '7/1/2023', - '8/1/2023', - '9/1/2023', - '10/1/2023', - '11/1/2023', - '12/1/2023' - ] - } + months = { + 'month': [ + '1/1/2023', + '2/1/2023', + '3/1/2023', + '4/1/2023', + '5/1/2023', + '6/1/2023', + '7/1/2023', + '8/1/2023', + '9/1/2023', + '10/1/2023', + '11/1/2023', + '12/1/2023' + ]} + demand.iloc[:, 0] = pd.DataFrame(months) # insert building_name to first column @@ -122,15 +123,14 @@ class EnergyValidation: TODO: number_of_adjacent_walls ''' formatted_metadata = pd.DataFrame({ - 'metadata': - [ - metadata.iloc[0, 0].split(': ')[1], - metadata.iloc[4, 0].split(': ')[1], - metadata.iloc[3, 0].split(': ')[1], - building_area, - metadata.iloc[6, 0].split(': ')[1], - metadata.iloc[1, 0].split(': ')[1], - metadata.iloc[2, 0].split(': ')[1] + 'metadata': [ + metadata.iloc[0, 0].split(': ')[1], + metadata.iloc[4, 0].split(': ')[1], + metadata.iloc[3, 0].split(': ')[1], + building_area, + metadata.iloc[6, 0].split(': ')[1], + metadata.iloc[1, 0].split(': ')[1], + metadata.iloc[2, 0].split(': ')[1] ]}).transpose() # last, but not least, append our lovely reformatted data to the results spreadsheet @@ -184,9 +184,9 @@ class EnergyValidation: demand['source'] = 'ep' # drop unneeded columns - demand.drop(4) - demand.drop(5) - demand.drop(6) + demand.drop(demand.columns[3], axis=1, inplace=True) + demand.drop(demand.columns[3], axis=1, inplace=True) + demand.drop(demand.columns[3], axis=1, inplace=True) # last, but not least, append our lovely reformatted data to the results spreadsheet with pd.ExcelWriter(self.result_file, engine='openpyxl', if_sheet_exists='overlay', mode='a') as writer: @@ -307,19 +307,17 @@ class EnergyValidation: 'NA', 'NA', 'NA', - 'NA' ]).transpose() - print(building_with_error) - # with pd.ExcelWriter(self.result_file, engine='openpyxl', if_sheet_exists='overlay', - # mode='a') as writer: - # building_with_error.to_excel( - # writer, - # startrow=writer.sheets['Simulation data'].max_row, - # sheet_name='Simulation data', - # index=False, - # header=False, - # ) + with pd.ExcelWriter(self.result_file, engine='openpyxl', if_sheet_exists='overlay', + mode='a') as writer: + building_with_error.to_excel( + writer, + startrow=writer.sheets['Simulation data'].max_row, + sheet_name='Simulation data', + index=False, + header=False, + ) if cleanup is True: [os.remove(os.path.join(self.tmp_folder, file)) for file in os.listdir(self.tmp_folder)] \ No newline at end of file diff --git a/main.py b/main.py index 3cb5190..4ad4696 100644 --- a/main.py +++ b/main.py @@ -16,4 +16,4 @@ test_batch = { validate_meb_ep = EnergyValidation() # if cleanup is True, removes all files in tmp directory -validate_meb_ep.run(building_set=buildings, building_quantities=test_batch, cleanup=True) +validate_meb_ep.run(building_set=buildings, building_quantities=test_batch, cleanup=False)