From 6042134412e84aae1c371072f2209542c79dd788 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Wed, 19 Dec 2018 11:02:19 +0100 Subject: [PATCH] Fix CSV generation --- sumo_project/emissions.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sumo_project/emissions.py b/sumo_project/emissions.py index 5c11a41..d155679 100644 --- a/sumo_project/emissions.py +++ b/sumo_project/emissions.py @@ -143,11 +143,10 @@ def export_data_to_csv(config, grid): writer = csv.writer(f) # Write CSV headers writer.writerow(itertools.chain(('Step',), (a.name for a in grid))) - emissions = (a.emissions_by_step for a in grid) - step = 0 - for em in emissions: - writer.writerow(itertools.chain((step,), (e.value() for e in em))) - step += 1 + # Write all areas emission value for each step + for step in range(config.n_steps): + em_for_step = (f'{a.emissions_by_step[step].value():.3f}' for a in grid) + writer.writerow(itertools.chain((step,), em_for_step)) def run(config, logger):