1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-22 03:26:30 +00:00

Added data to csv export

This commit is contained in:
Ahp06 2018-12-16 15:44:33 +01:00
parent c76eea9d76
commit 229ab72279

View File

@ -133,23 +133,21 @@ def export_data_to_csv(config, grid):
'''if not os.path.exists(f'csv/{current_date}'):
os.makedirs(f'csv/{current_date}')'''
'''with open(f'test.csv', mode='w', newline = '') as emission_file:
with open(f'test.csv', mode='w', newline = '') as emission_file:
try:
csv_writer = csv.writer(emission_file, delimiter = '', quoting=csv.QUOTE_MINIMAL)
a = list(range(config.n_steps))
csv_writer = csv.writer(emission_file, delimiter = ' ', quoting=csv.QUOTE_MINIMAL)
csv_writer.writerow(['steps'])
a = list(range(config.n_steps))
for item in a:
csv_writer.writerow([item])
for area in grid:
writer = csv.writer(emission_file, delimiter = ' ', quoting=csv.QUOTE_MINIMAL)
writer.writerow([f'{area.name}'])
csv_writer.writerow([f'{area.name}'])
for emission in area.emissions_by_step:
writer.writerow([emission.value()])
csv_writer.writerow([emission.value()])
finally:
emission_file.close()'''
emission_file.close()
def run(config, logger):
@ -161,7 +159,6 @@ def run(config, logger):
start = time.perf_counter()
grid = init_grid(traci.simulation.getNetBoundary(), config.areas_number, config.window_size)
export_data_to_csv(config,grid)
add_data_to_areas(grid)
loading_time = round(time.perf_counter() - start, 2)
@ -180,6 +177,7 @@ def run(config, logger):
finally:
traci.close(False)
export_data_to_csv(config,grid)
simulation_time = round(time.perf_counter() - start, 2)
logger.info(f'End of the simulation ({simulation_time}s)')