From af7e5a3b3be6e9ca82eef4b4e340b1c7e6ef6115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Solbj=C3=B8rg?= Date: Thu, 23 Feb 2023 19:08:52 +0100 Subject: feat(koblingsplan): Write YAML to file --- tools/koblingsplan/script.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools/koblingsplan/script.py') diff --git a/tools/koblingsplan/script.py b/tools/koblingsplan/script.py index c27eda9..8fdc518 100644 --- a/tools/koblingsplan/script.py +++ b/tools/koblingsplan/script.py @@ -8,6 +8,9 @@ import csv import yaml +# Holds all data. List of objects, each object represents a row in the table +dataset = [] + with open('tg23-koblingsplan.csv', newline='') as csvfile: csv_data = csv.reader(csvfile, delimiter=',', quotechar='"') @@ -17,9 +20,6 @@ with open('tg23-koblingsplan.csv', newline='') as csvfile: # Holds the data from the current iteration current_iteration = {} - # Holds all data. List of objects, each object represents a row in the table - dataset = [] - for row in csv_data: i += 1 # skip first 2 lines, they only contain table headers @@ -54,4 +54,5 @@ with open('tg23-koblingsplan.csv', newline='') as csvfile: dataset.append(current_iteration) - print(yaml.dump(dataset, default_flow_style=False, sort_keys=False, allow_unicode=True)) +with open('tg23-koblingsplan.yml', 'w') as f: + f.write(yaml.dump(dataset, default_flow_style=False, sort_keys=False, allow_unicode=True)) -- cgit v1.2.3