Skip to content

Commit

Permalink
Move json-specific columns to right of non-json-specific columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Staberinde committed Apr 4, 2022
1 parent b481ae2 commit 3943496
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion digital_land/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import OrderedDict
import csv
import itertools
import os
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3943496

Please sign in to comment.