From 39434968faf937719f78851ae238cce4d1065486 Mon Sep 17 00:00:00 2001 From: Toby Petty Date: Mon, 4 Apr 2022 12:07:04 +0100 Subject: [PATCH] Move json-specific columns to right of non-json-specific columns --- digital_land/api.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/digital_land/api.py b/digital_land/api.py index 00ce8aa9..1b2fac40 100644 --- a/digital_land/api.py +++ b/digital_land/api.py @@ -1,3 +1,4 @@ +from collections import OrderedDict import csv import itertools import os @@ -262,10 +263,14 @@ def dataset_dump_hoisted_cmd(self, sqlite_path, csv_path, hoisted_csv_path): ] ) ] - field_names = set(spec_field_names + reader.fieldnames) + hoisted_field_names = set(spec_field_names).difference( + set(list(reader.fieldnames)) + ) + field_names = list(reader.fieldnames) + list(hoisted_field_names) writer = csv.DictWriter(write_file, fieldnames=field_names) writer.writeheader() for row in reader: + row = OrderedDict(row) json_string = row.pop("json") or "{}" row.update(json.loads(json_string)) snake_case_row = dict(